Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2011, 11:18 AM   PM User | #1
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
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?
Apothem is offline   Reply With Quote
Old 02-01-2011, 11:37 AM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Old 02-07-2011, 12:33 AM   PM User | #3
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
Wait so how do I make it run index.py or something if I go to mysite.com?
Apothem is offline   Reply With Quote
Old 02-07-2011, 12:57 AM   PM User | #4
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Old 02-07-2011, 09:47 AM   PM User | #5
Apothem
Regular Coder

 
Apothem's Avatar
 
Join Date: Mar 2008
Posts: 380
Thanks: 36
Thanked 25 Times in 25 Posts
Apothem is an unknown quantity at this point
Well I read it more "thoroughly" but still don't see anything about how to make a file the index page.
Apothem is offline   Reply With Quote
Old 02-07-2011, 10:22 AM   PM User | #6
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
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
oesxyl is offline   Reply With Quote
Old 03-01-2011, 12:07 AM   PM User | #7
Samhain13
Regular Coder

 
Samhain13's Avatar
 
Join Date: Aug 2008
Location: Pilipinas
Posts: 165
Thanks: 4
Thanked 18 Times in 18 Posts
Samhain13 is on a distinguished road
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 **
Samhain13 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:07 AM.


Advertisement
Log in to turn off these ads.