Quickly build a web. py development framework in windows.
There are many frameworks to choose from for web development using Python, such as the most famous Django and tornado frameworks. In addition to these frameworks, it is very convenient and convenient to use a lightweight framework, web. py. It was created by a hacker, but unfortunately the Creator committed suicide in 2013. It is said that another person is maintaining and updating the service. Now let's take a look at how to build a web. py development environment in windows.
1. Install web. py
Download the web.pyinstallation package at https://github.com/webpy/webpy. Note that github requires a browser version, for example, less than IE9 is not supported.
Download the corresponding version as needed.
Download the package, decompress it, open cmd, cd to the decompressed directory, and enter
Python setup. py install
The installation is complete. (Python and python 3 or earlier must be installed)
Ii. test procedures.
Create a hello. py file
Import web
Urls = ('/hello', 'Hello ',
)
Class hello (object ):
Def GET (self ):
Return 'Hello world'
If _ name _ = "_ main __":
App = web. application (urls, globals ())
App. run ()
Urls is a url ing rule (similar to the servlet ing in servlet), and hello is a link request response.
Then run the file in the command line:
If you want to stop the program Ctrl + C, you can exit. By default, the program runs on port 8080. Then, enter http: // 127.0.0.1: 8080/hello in the browser to view the result:
The program runs on port 8080 by default. If port 8080 is occupied by other programs, the web. py program fails to run. For example, the sockets. error occurs. You need to change the Port:
Note that web. py does not support website deployment. Therefore, web. py programs can only be accessed locally. apache or nginx must be used for deployment.