Reputation: 26922
I'm looking for the fast, easy (all default settings) way of installing Python on my windows machine so that Apache can use it. I currently have a Windows 7 installation with Apache and PHP working. I want to try and make some simple web pages in Python, just to play around with Python for a bit and learn a thing or two. I downloaded and installed Python 3.2 Python 2.7.2 (As advised below). What do I do next? I would like to make a "Hello World". Do I need mod_python or can I do without? I assume I need to tell Apache somehow that Python is available. I probably need to make an "index.py" file, or something similar?
I'm not directly looking for tutorials on the Python language itself, but just for some steps to make the simplest of the simplest script (Hello World) work on my current system.
Basically I'm looking for the Python equivalent of the following php script to work in my Apache:
<html>
<head>
<title>Hello World</title>
</head>
<body>
<?= "Hello World"; ?>
</body>
</html>
Upvotes: 3
Views: 11233
Reputation: 318508
First of all, especially in the web sector it's better to stay with python 2 (2.7) for now. Lots of frameworks and libraries are not py3-ready yet.
Then you might want to use mod_wsgi instead of mod_python which is deprecated and not available in binary form for recent python versions (and using old python versions such as 2.5 is bad).
Finally, unlike PHP it's usually not a good idea to write python webapplications with the idea of 1:1 mappings between files and urls. To get started with something nice, have a look at the Flask microframework. It has some good examples and a full tutorial. And to make it even better, you don't need Apache for it during development as you can simply run a python-based developmont server.
Upvotes: 4
Reputation: 28005
You can use mod_python (deprecated and not recommended) or better mod_wsgi
.
Look at:
Django docs - How to use Django with Apache and mod_wsgi - the information is sufficient to set up Apache and mod_wsgi.
this question there, where there is an example of setting up mod_wsgi
using cherrypy.
Upvotes: 3