Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Low Level Request Handling
#3
(Mar-14-2017, 10:05 AM)c0da Wrote: Hello all,
I'm new to Python and try to find out how useful it is for web programming.

I searched the web, but I couldn't find an answer to how to send data from my browser to
my Python program on the server, without using frameworks.

Is there an eqiuvalent to the php GET and POST commands?

How do I send the input, generated by a HTML form to a Python Program on my server?
Thank you!

GET/POST are faily high level commands. In Python see the requests module (non-standard, but very popular). Otherwise use the urllib or urllib2 modules.

Typical use of requests:
import json,requests

headers={'Content-type':'application/json'}
auth=('someid', 'somepwd')
parameters={"foo":"bar"} // as a python dictionary
url="http://someserver/somerequest/"

req=requests.post(url,auth=auth,headers=headers,data=json.dumps(parameters))
jsonresponse=req.json()
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
Low Level Request Handling - by c0da - Mar-14-2017, 10:05 AM
RE: Low Level Request Handling - by wavic - Mar-14-2017, 10:31 AM
RE: Low Level Request Handling - by Ofnuts - Mar-14-2017, 12:05 PM
RE: Low Level Request Handling - by snippsat - Mar-14-2017, 03:00 PM
RE: Low Level Request Handling - by Ofnuts - Mar-14-2017, 06:07 PM
RE: Low Level Request Handling - by snippsat - Mar-14-2017, 06:26 PM
RE: Low Level Request Handling - by wavic - Mar-14-2017, 06:29 PM
RE: Low Level Request Handling - by snippsat - Mar-14-2017, 06:37 PM
RE: Low Level Request Handling - by wavic - Mar-14-2017, 06:54 PM
RE: Low Level Request Handling - by snippsat - Mar-14-2017, 07:02 PM
RE: Low Level Request Handling - by c0da - Mar-15-2017, 01:21 PM
RE: Low Level Request Handling - by snippsat - Mar-15-2017, 03:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python handling Apache Request harzsr 3 3,879 Nov-16-2018, 04:36 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020