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

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0

    Python and the web


    Couple questions to ask:

    1) building a website on my desktop and everytime i write the html code i have to save it both as text and as .htm its kind of annoying. isn't there anyway to kind of automate it.

    2)I want to use python on the server side and i'ld like to have a a from submission go to say clien_parser.py. after i link it to the script does it go there automatically or do i need to be using the cgi bin info from python. Basically the question is how do i get the form to go to the script and how do i get python to read and process the info.

    3)I forgot the third. i'll remember:
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    89
    Rep Power
    13
    Originally Posted by caroundw5h
    Couple questions to ask:

    1) building a website on my desktop and everytime i write the html code i have to save it both as text and as .htm its kind of annoying. isn't there anyway to kind of automate it.

    2)I want to use python on the server side and i'ld like to have a a from submission go to say clien_parser.py. after i link it to the script does it go there automatically or do i need to be using the cgi bin info from python. Basically the question is how do i get the form to go to the script and how do i get python to read and process the info.

    3)I forgot the third. i'll remember:
    1) I don't understand this part, why do you have to save it as .txt?

    2) you direct the form data to the script in your HTML form

    example: <form action="clien_parser.py" name="pyform" method="post">

    if you want to do CGI with python, read the devshed tutorial http://www.devshed.com/c/a/Python/Wr...ams-in-Python/
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0
    Originally Posted by jimmy2k1
    1) I don't understand this part, why do you have to save it as .txt?

    2) you direct the form data to the script in your HTML form

    example: <form action="clien_parser.py" name="pyform" method="post">

    if you want to do CGI with python, read the devshed tutorial http://www.devshed.com/c/a/Python/Wr...ams-in-Python/
    Thank you for answering.

    I first save it as text so that i can manipulate easier. I've read some tutorials that told me if i want to do so i need to save it as a text and not htm.

    2) in your example name = "pyform" is that the mandatory attribute or generic?

    3)Thank you for you link i appreaciate it.
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Well, you dont have to write anything to a text file and i can't see how it could be easier since data read in from a file is just a string. So if you just want to manipulate it then theres no need, but then maybe theres something your not telling. And just to clear things up a little , the file extention means nothing to Python so anything you like...

    What server are you trying to run this from anyway or do you just want to have the app serverless, if so then you should look at the CGIHTTPServer module.

    http://www.python.org/doc/2.3.3/lib/...TTPServer.html

    Hope this helps.

    Mark

    P.S. The name of the form (like all other element names) is generic
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0
    Originally Posted by netytan
    Well, you dont have to write anything to a text file and i can't see how it could be easier since data read in from a file is just a string. So if you just want to manipulate it then theres no need, but then maybe theres something your not telling. And just to clear things up a little , the file extention means nothing to Python so anything you like...

    What server are you trying to run this from anyway or do you just want to have the app serverless, if so then you should look at the CGIHTTPServer module.

    http://www.python.org/doc/2.3.3/lib/...TTPServer.html

    Hope this helps.

    Mark

    P.S. The name of the form (like all other element names) is generic
    Thank you for your reply Net. I'm creating the webpage on my personal computer, i have not uploaded it to server as yet. however i would like to be able to use the cgi module and see how it is used and without uploading my page to a server. it seems that is what you were sayingwith the CGIHTTPSERVER Module, so i'll check it out.

    I still don't get what your talking about with the text file though. I want to create a webpage so i go into notepad and right the necessary script, then i save it as htm. is that what your saying. what happens when i want to edit the script? then i have to copy and paste it onto notepad manipulate it and then save it again.

    If i save it as text, all i do is manipulate the text file and save a copy as htm and as text, that way i don't do any copy and paste. hope this clears it up and what i do. If there is a better way i'ld love to hear it as you can see i'm a web developing novice.
    thanks again for your reply.
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    I want to create a webpage so i go into notepad and right the necessary script, then i save it as htm. is that what your saying. what happens when i want to edit the script? then i have to copy and paste it onto notepad manipulate it and then save it again.
    When you want to edit the file, open the HTML file in notepad.
    Or, better yet, don't close notepad, just save the file before viewing the changes.

    Even better, don't use notepad. Try EditPlus, or Textpad or one of the other free text editors that do syntax highlighting, etc.
  12. #7
  13. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    The content of html files is just plain text.

    You can edit and save html files using Notepad.

    There are plenty of Free Text Editors on the web which make editing html files easier. For example - when you use the open file dialog they show your html files without you having to change the file type settings.

    Your tutorial probably warned you not to use a word processor program like Wordpad or Word. They can add funny codes and mess things up.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0
    Originally Posted by sfb
    When you want to edit the file, open the HTML file in notepad.
    Or, better yet, don't close notepad, just save the file before viewing the changes.

    Even better, don't use notepad. Try EditPlus, or Textpad or one of the other free text editors that do syntax highlighting, etc.
    Tahnk you so much, that saves me soooo much time.

    Now next question: Can i use PWS on windows to turn my computer into a server, that way i can test out the cgi capabilities. I'm on windows xp. I hope this isn't a stupid question but i've heard about it, thats why.
    Last edited by caroundw5h; April 1st, 2004 at 07:37 PM.
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  16. #9
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    In theory yes although i havn't used it since Apache beats it hads down every time! So if you can get Apache, you wont regret it

    Mark.
    programming language development: www.netytan.com Hula

  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    M$ say that PWS is not supported on Windows XP, and I have heard reports that it will not run at all. On the other hand I could never get PWS to run on Windows 98 either.

    My advice is to avoid it like the plague and use a decent web server like Apache. If you need ASP functionality then take a look at AHTML from Selisoft (http://www.selisoft.com/en/ahtml/), which does a reasonable job of providing ASP emulation under Apache and other servers. There are other products that do this but they are priced in the hundreds of dollars range, while AHTML is about $30.

    Dave - The Developers' Coach
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0
    Thank you for your responses. I guess what i'm asking is can i run apache or a server on my home computer and still use it as a personal computer. I only want to test the cgi output. I will take a look at apache however. Thank you.

    While we are at it. Can you tell me exactly what a Server is. I know it is a dedicated computer to hold info, but why do you need speacial sofware like apache. technically isn't being connected to the net enough? i mean ppl want to see your home page, they can just log on to your site, that you store on your own computer right? what does apache, cheetah and all the others do that is so speacial?
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."


IMN logo majestic logo threadwatch logo seochat tools logo