Install the Python web.py Framework and start programming from Hello World _python

Source: Internet
Author: User

Recently there was a small Web project that wanted to use Python as a favorite, but I felt a shudder at the thought of previous contact, why? Django's configuration is too complex, and small projects are not suitable for the MVC development model, so I look to web.py this small web framework, and really I am tempted to all of its official website is a word: "Django lets you write Web apps in Django. TurboGears lets you are write Web apps in TurboGears. web.py lets you write Web apps in Python. "-adam Atlas

Recently switched Ubuntu to replace the Win7 system, so here's a description of Ubuntu installed web.py
Install Easy_install

sudo apt-get install Python-pip

Use Easy_install to install web.py

sudo easy_install web.py

Test whether the installation was successful:

Executing in the Python shell:

Import Web

If there is no error, the web.py installation succeeds. Here we go, our first hello,world.

Import Web

urls = ("/.*", "Hello")        # Specifies that any URL points
to the Hello class app = Web.application (URLs, Globals ()) # binding URL

# definition Corresponding class class
Hello:
def get (self): return
' Hello, world! '

if __name__ = = "__main__":
App.run ()

Then save it as hello.py and run it

Python hello.py

Then you'll see the output: http://0.0.0.0:8080/

Then browser access: http://localhost:8080 can see Hello, world! The first Web program we wrote in Python was built.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.