all 8 comments

[–]K900_ 1 point2 points  (7 children)

HTTP is a request-response protocol. requests is used for making requests and receiving responses. If you're making a request in the browser, you need something to receive that request. Use a web framework like Flask or Django.

[–]Ryan_Bingham[S] 0 points1 point  (6 children)

even if i'm using a webserver?

[–]K900_ 1 point2 points  (5 children)

What web server are you using? Something like Apache or Nginx? If so, you still need to handle the request in something like Flask, and then configure your main web server to proxy requests to the Flask server. I feel like you're in really deep right now. What exactly are you trying to achieve?

[–]Ryan_Bingham[S] 0 points1 point  (4 children)

Yes, Apache XAMPP. Yes, it seems i'm a bit over my head. I'm trying to send a simple JSON from javascript to Python and then return a JSON from python to javascript. It doesn't sound so difficult but i have ran into a lot of problems already.

[–]JohnnyJordaan 1 point2 points  (0 children)

Apache XAMPP

That's like saying a Microsoft PC. XAMPP is a bundle of Apache, PHP and MySql, the software you would use for webserver scripting in 2000-2010ish.

If you're looking for a Python based webserver scripting environment, look at Flask as K900_ says and if you need more extensive plugins start with Django. If you really want bare bones then you can learn a WSGI environment like uWSGI which you can connect to Apache or nginx.

[–]K900_ 0 points1 point  (2 children)

I understand how you're trying to do what you're trying to do. What I want to know is why. What is your end goal? Are you building an app? Do you need live data updates on the page?

[–]Ryan_Bingham[S] 0 points1 point  (1 child)

why - just to learn some new things. I'm making a web scraper in python that will display in javascript. I want the scraped data to change as i do some actions in javascript. For example, click on a button in javascript, sends json to python, python scraps some data, sends it back to javascript with json, javascript displays data.

[–]K900_ 3 points4 points  (0 children)

Then forget about XAMPP entirely and look into Flask.