[Tutor] python cgi single double quotes
nitin chandra
nitinchandra1 at gmail.com
Wed Jul 20 05:09:25 EDT 2016
On inserting the line ...
print "<p> + "sys.version + "</p>"
required slight correction
print "<p>" + sys.version + "</p>"
and the following script and its output are below :-
----------------------------------------
#!/usr/bin/env python
import sys
import cgi
import psycopg2
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print "<p>"+ sys.version + "</p>"
print 'First name: <input type="text" name="fname"><br>'
print '</body>'
print '</html>'
---------------------------------------------------
Hello Word! This is my first CGI program
2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]
First name:
On 20 July 2016 at 14:14, Alan Gauld via Tutor <tutor at python.org> wrote:
> On 20/07/16 09:23, nitin chandra wrote:
>
>> vimal at Ubuntu-1404-trusty-64-minimal:~$ python
>> Python 2.7.6 (default, Jun 22 2015, 17:58:13)
>> [GCC 4.8.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import sys
>>>>> print sys.version
>> 2.7.6 (default, Jun 22 2015, 17:58:13)
>> [GCC 4.8.2]
>>>>>
>>
>> Should I test the above from within html code too ?
>
> Yes, that's what I meant to imply by putting it
> inside <p> markers:
>
>>> import sys
>>> ...
>>> print "<p> + "sys.version + "</p>"
>>> ...
>
> The idea is to make sure that the web server is
> running the same version of Python that you are.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list