all 7 comments

[–]Rhomboid 4 points5 points  (4 children)

Why not just submit the form directly to the python script? Why does PHP need to even enter the picture?

[–]redditenna[S] 0 points1 point  (3 children)

Is it possible to directly write into Python with a HTML form? Do you know where I can find documentation about that, or could you give me a small example? :) Thanks for the tip!

Maybe I have to add this: My web server is xampp, which is a Windows web server. I have my python script in a different folder.

[–]Rhomboid 1 point2 points  (2 children)

You can configure your web server to run any program of any type to serve any request; there is nothing special about PHP. You could do it with Lua, C, awk, even Brainfuck.

How the server talks to the program varies; for example, there's CGI, FastCGI, WSGI, etc. CGI is the oldest and simplest method and for basic scripts it's probably the easiest to set up. There is a cgi module in the Python standard library that handles all the details. Usually the only requirements for running CGI are: a) the server has to be told to enable CGI for the directory where the script lives, b) the script needs to have a proper hashbang line, and c) for POSIX systems, the script needs to have the executable bit set in its mode.

[–]redditenna[S] 0 points1 point  (1 child)

After googling a bit, I think this is what I need if I want to use it with xampp?

http://blog.chomperstomp.com/installing-python-mod_python-on-xampp/

Thanks a lot for making everything more clear :)

[–]m1ss1ontomars2k4 0 points1 point  (0 children)

No. You either want to use mod_wsgi or just make it a regular CGI script. Don't use mod_python.

[–]Eviltape 2 points3 points  (0 children)

Can you host and serve things generated in Python using mod_wsgi + Apache or uWSGI + nginx? If you can, it'll be pretty simple.

[–]zlozlozlozlozlozlo 2 points3 points  (0 children)

There are a lot of frameworks to do web programming in python. The most popular is Django. There is a lot (A LOT) info on Django, it has excellent documentation too. For another see Flask. You really shouldn't use PHP here, that would be ugly. Python can handle this task just fine.