Typically PHP scripts are accessed directly, similarly to a CGI script - basically you access the script like any regular file, but the web server intercepts this request, runs the script and returns the output instead of the file contents.
Most Python frameworks have their own routing systems, where you define something like..
urls = (
('^/article/(\d+)$', ArticleController),
('^/user/(.+?)$', UserController)
)
..then you would access something like..
http://example.com/router.py?uri=article/123
..and it would be run through the URL mapping defined in urls
, and send the request to the appropriate class... but having the router.py
part in all your URLs is a bit crappy, so you use mod_rewrite
to redirect /(.*)
to /router.py/$1
(either via .htaccess
, your Apache configuration etc)
You can absolutely do the same thing with PHP, or any other language - this is exactly how CodeIgniter works (a PHP framework)
If you are utterly insane, you could use mod_rewrite
and map /user/(\d+).py
to /ViewController.php?id=$1
or something, but there's generally no point to adding a fake extension to the page (there's a few exceptions, mainly backwards compatibility, and allowing access to data in different formats in an API)
You can also do the "PHP way" using Python, if you write each page as a separate CGI script, just most Python frameworks tend to use the MVC (or MVC-like) setup I described above..
5head over to stackoverflow.com for more help with python +++ – pavsaund – 2009-07-26T18:30:50.447
1
a related question is now at http://stackoverflow.com/questions/1185248/is-python-only-for-building-backends-when-you-need-to-write-sql-by-hand
– Léo Léopold Hertz 준영 – 2009-07-26T19:34:45.270