How would one use Python as a PHP alternative?

If there a hello world example somewhere?

Recommended Answers

All 2 Replies

You have to use some sort of web framework,
Ruby by itself doesn't work on the web, so that's why there is Rails.

Same thing with Python,
you have to use something like Django, web2py, pylons, etc.

You can use cgi module,work in way same as php.
The other way is as postet over use to use web framework.

To test cgi you have to run a webserver like xampp.
To set up xampp look here.
http://jerryoem.spaces.live.com/Blog/cns!4032172F84519E20!342.entry
Then you can run python script in browser.

This will print hello world in your browser.

#!C:/python26/python.exe 
print "Content-type: text/html\n\n"

print('''\
<html>
<head>
<title>Hello</title>
</head>
<body>
Hello world!
</body>
</html>
''')

Links for cgi.
http://www.tutorialspoint.com/python/python_cgi_programming.htm
http://webpython.codepoint.net/cgi_tutorial

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.