Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start creating websites by using Python

Tags:

python

I am basically a PHP guy. now moving towards python. I am starting to learn python.

How do I install it and start working it, and develop websites . I got totally confused with the alternative implementations in the download section of the Python site. Can you tell me what "alternative implementations" means?.

I mean to say: I can create a .php file in my server and then access it from browser like http://example.com/index.php, so I was wondering whether I can do the same with python, like creating a .py file and accessing from browser http://example.com/index.py.

like image 453
Hacker Avatar asked May 11 '11 14:05

Hacker


2 Answers

Just as a disclaimer, I interpret you saying "run Python in a browser" as "making a website with Python."

If you want to start writing web applications in Python, you can either use CGI or use one of its many web app frameworks. Python is not like PHP in the sense that you can't just embed it in HTML. Many of those frameworks come with development servers that you can use to test your web app (by looking at it in a browser).

A particularly good Python web framework is Django.

I really do recommend that you do the Python tutorial before you dive into any of those frameworks, though. Python is not only for writing web applications, so you'll have to get some fundamentals down first before any of that makes sense to you.

As for installing Python, I recommend you take the version you got with your OS if you use Mac or Linux, or installing the Python 2.7.1 32-bit binary from python.org if you use Windows. The alternative implementations include a Python that runs on the Java virtual machine and one that runs on the .NET Common Language Runtime, but for your purposes the reference implementation, CPython, should work fine.

like image 95
Rafe Kettler Avatar answered Nov 15 '22 17:11

Rafe Kettler


Python by default is a general purpose scripting language and is not meant specifically for web application development (like PHP is primarily). So, you'll first need to download and install Python (choose the version that's appropriate for your OS) from www.python.org I'd recommend v2.7.1 but you can try out v3.2 if you'd like.

The other versions (IronPython, Jython, etc) are Python implementations on other platforms (.NET and JVM respectively), and in all likelihood you don't need to bother with them unless you really want to.

To start working with Python and create web applications you will also need to download and install a Python-based web framework. There are many of them, too many in fact to list here. However, there is a page on the Python Wiki that has a list of useful frameworks for web development.

like image 26
Brian Driscoll Avatar answered Nov 15 '22 16:11

Brian Driscoll