#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    4
    Rep Power
    0

    using python on a webpage


    Well, I want to learn a programming language, but I want to learn one that will enable me to make programs that can be run on a webpage. Can python do this?

    Could I get python to store information on a site and make a login (user, and password) form with it?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    6
    Rep Power
    0
    Sure

    Python can do CGI's heres an example the example below takes a password and a username from a user submitted form and if there password is chicken allows them to view your page.

    import cgi<br>
    form = cgi.FieldStorage()<br>
    name = form['name'].value<br>
    password = form['password'].value<br>
    <br>
    if password == chicken:<br>
    &nbsp;&nbsp;&nbsp; print 'Content-type: text/html'<br>
    &nbsp;&nbsp;&nbsp; print<br>
    &nbsp;&nbsp;&nbsp; print 'hi',name ' &lt;h1&gt; welcome to this
    site&lt;/h1&gt;<br>
    <br>
    else:<br>
    &nbsp;&nbsp;&nbsp; print 'Content-type: text/html'<br>
    &nbsp;&nbsp;&nbsp; print<br>
    &nbsp;&nbsp;&nbsp; print 'your user name or password is incorrect go
    away'<br>
    &nbsp;&nbsp; &nbsp;<br>
    <br>
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    There are quite a few ways that you can use Python to create dynamic web pages other than CGI. For example mod_python; includes PSP.

    Then There's Spyce, Zope, CherryPy, Quixote... the list goes on... and on... In fact there are so many that it's not always that easy to choose which one to use .

    If you're interested you can find more on these systems on Google or at:

    http://www.python.org/topics/web/

    Mark.
    Last edited by netytan; November 7th, 2004 at 11:42 AM.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo