Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts

    Do you have to rewrite URLs for Python?

    So for my webhost, index.py is not automatically called when a user goes to mysite.com. Is there another file name that is conventionally used in Python that is automatically called as the index file?

    And also making sure: You are required to use mod_rewrite to get "nicer" URLs from Python. To add to it, how does Python distinguish GET request variables from POST request variables?

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Apothem View Post
    So for my webhost, index.py is not automatically called when a user goes to mysite.com. Is there another file name that is conventionally used in Python that is automatically called as the index file?

    And also making sure: You are required to use mod_rewrite to get "nicer" URLs from Python. To add to it, how does Python distinguish GET request variables from POST request variables?
    now is clear for me why do you ask about import in your other thread,
    you make a huge confusion, python can be used as a client side language for a web site but is a scripting language like any other, you need to use your script as a cgi script.

    read this first:
    http://docs.python.org/library/cgi.html

    best regards

  • #3
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts
    Wait so how do I make it run index.py or something if I go to mysite.com?

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Apothem View Post
    Wait so how do I make it run index.py or something if I go to mysite.com?
    did you read this?

    http://docs.python.org/library/cgi.h...-a-unix-system

    the page from that link explain step by step what to do. Try and when you have problem ask i will try to help you.

    best regards

  • #5
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts
    Well I read it more "thoroughly" but still don't see anything about how to make a file the index page.

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Apothem View Post
    Well I read it more "thoroughly" but still don't see anything about how to make a file the index page.
    you don't have any index page. The idea of using cgi is to get and process requests and to generate the content of the page and sent to who request the page.
    More exactly:

    1. somebody ask your server to show a page http://example.com/mypage
    2. the server send the name of the page, mypage to the cgi script
    3. the script generate the page and write the result to the stdout.

    you need to understand what is and how cgi work but this have nothing to do with python. For cgi you can use any language,

    Edit: there is a convention, when mypage is '', http://example.com/ then the server return the index page, index.html, index.php, or how ever are the server settings

    best regards

  • #7
    Regular Coder Samhain13's Avatar
    Join Date
    Aug 2008
    Location
    Pilipinas
    Posts
    169
    Thanks
    4
    Thanked 18 Times in 18 Posts
    Quote Originally Posted by Apothem View Post
    So for my webhost, index.py is not automatically called when a user goes to mysite.com. Is there another file name that is conventionally used in Python that is automatically called as the index file?
    If your server allows you to use .htaccess (like in Apache), try this:

    Code:
    # This is a .htaccess file.
    # Tell the server to treat .py files as CGI scripts:
    AddHandler cgi-scipt .py
    
    # Tell the server that index.py should be the directory's index page.
    DirectoryIndex index.py
    Of course, under a Unix system, the index.py file should be executable or having a mode like 755.
    I am a Man of Truth. I am a Free Human Person. I am a Peacemaker.
    ** Independent Multimedia Artist in Pasig **


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •