Web. py is a lightweight Python Web framework that is simple and powerful.

Web. py is a Python Web framework that is simple and powerful. Web.py is public and there is no limit to what it can be used for. It’s pretty small and should belong in a lightweight Web framework.

First install Webpy using PIP/PIp3

pip install web.py

The latest version 0.61 requires Python >= 3.5

Version 0.51 requires Python 2.7

Here’s an example to get started with, app.py

import web urls = ( '/(.*)', 'hello' ) app = web.application(urls, globals()) class hello: def GET(self, name): if not name: name = 'World' return 'Hello, ' + name + '! ' if __name__ == "__main__": app.run()Copy the code

Start run command:

python3 app.py

Default port bit 8080, browser access http://0.0.0.0:8080/

The project starts preparing requirements.txt web.py==0.62 and then starts writing our first template

#! /usr/bin/python # -*- coding:utf8 -*- import web,os urls = ('/','index') render = web.template.render('templates/') Class index: def GET(self): name = '__main__' return render. Index (name) if __name__ == "__main__": app = web.application(urls,globals()) app.run()Copy the code

Project source code address: gitee.com/shuogesha/p…