Lesson - 66 : Python Advanced - Python CGI Programming : Passing Information Using POST Method

Published: 23 January 2018
on channel: Sada Learning Hub
982
7

**************************************************
before watching this video please whatch this video to configure your setup    • Lesson - 62 : Python Advanced - Python CGI...  
Python Core PlayList :    • Lesson - 01 : Python3 - What is python  
Python Advanced PlayList :    • Lesson - 46 : Python Advanced - Python OOP...  
**************************************************

Python CGI Programming : Passing Information Using POST Method:
A generally more reliable method of passing information to a CGI program is the POST method. This packages the information in exactly the same way as GET methods, but instead of sending it as a text string after a ? in the URL it sends it as a separate message. This message comes into the CGI script in the form of the standard input.
Below is same hello_get.py script which handles GET as well as POST method.
Example :
#!/usr/bin/python
Import modules for CGI handling
import cgi, cgitb
Create instance of FieldStorage
form = cgi.FieldStorage()
Get data from fields
first_name = form.getvalue('first_name')
last_name = form.getvalue('last_name')
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Hello - Second CGI Program</title>"
print "</head>"
print "<body>"
print "<h2>Hello %s %s</h2>" % (first_name, last_name)
print "</body>"
print "</html>”

<form action="/cgi-bin/hello_get.py" method="post">
First Name: <input type="text" name="first_name"><br /> Last Name: <input type="text" name="last_name" /> <input type="submit" value="Submit" />
</form>

Sample Projects : https://github.com/SadaLearningHub1/P...


On this page of the site you can watch the video online Lesson - 66 : Python Advanced - Python CGI Programming : Passing Information Using POST Method with a duration of hours minute second in good quality, which was uploaded by the user Sada Learning Hub 23 January 2018, share the link with friends and acquaintances, this video has already been watched 982 times on youtube and it was liked by 7 viewers. Enjoy your viewing!