Install the Python web. py framework and start programming from hello world, pythonweb. py

Source: Internet
Author: User

Install the Python web. py framework and start programming from hello world, pythonweb. py

Recently there was a small web project that wanted to use python as a favorite, but I felt chilling when I thought that I had been familiar with django before. Why? The configuration of Django is too complex and small projects are not suitable for the MVC development mode, so I turn to the web. py is a small web framework, and it makes me feel like it is a word on its official website: "Django lets you write web apps in Django. turboGears lets you write web apps in TurboGears. web. py lets you write web apps in Python. "-Adam Atlas

I recently switched to Ubuntu and replaced Windows 7. So here we will introduce how to install web. py on Ubuntu.
Install easy_install

sudo apt-get install python-pip

Install web. py with easy_install

sudo easy_install web.py

Test whether the installation is successful:

Run the following command in python shell:

import web

If no error is reported, web. py is successfully installed. The first hello, world

Import weburls = ("/. * "," hello ") # specify that any url points to the hello class app = web. application (urls, globals () # bind a url # define the class hello: def GET (self): return 'hello, world! 'If _ name _ = "_ main _": app. run ()

Save it as hello. py and run it.

python hello.py

The output is http: // 0.0.0.0: 8080/

Then visit: http: // localhost: 8080 in the browser to see Hello, world! We established the first web program written in python.

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.