How to quickly build the web.py development framework under windows

This article is reproduced from: http://www.cnblogs.com/dolphin0520/p/3343617.html Author: dolphin0520 Please indicate the statement when reprinting.

How to quickly build the web.py development framework                     under windows

  If you use Python for web development, there are many frameworks to choose from, such as the most famous Django, tornado, etc. In addition to these frameworks, there is a lightweight framework that is very convenient and easy to use, namely web.py. It was created by a hacker who unfortunately committed suicide in 2013. It is said to be maintained and updated by another person now. Now let's learn how to build a web.py development environment under windows.

1. Install web.py

  Download the web.py installation package at https://github.com/webpy/webpy . Note that github has requirements for browser versions, such as those that do not support IE9 and below.

  

  Download the appropriate version according to your needs.

  After downloading, unzip it, open cmd, cd to the unzip directory, and enter

  python setup.py install

  Installation is complete. (The premise is that python must be installed, and the version below python3)

2. Test procedure.

  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 are url mapping rules (similar to mapping in servlet), class hello is link request response.

  Then run the file on the command line:

  

   If you want to stop the program Ctrl+C can exit. The default program runs on port 8080, and then enter: http://127.0.0.1:8080/hello in the browser , you can see the result:

  

   The program runs on port 8080 by default, and if the port 8080 is occupied by other programs, the web.py program will fail to run, for example, an error such as sockets.error will occur. At this time, the port needs to be changed:

  

  

  Note that web.py does not have the ability to deploy websites, so the web.py program can only be accessed locally. If you want to deploy, you must use apache or nginx.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324151937&siteId=291194637
Recommended