Flask is another lightweight web framework in Python, with nearly 15000 star on GitHub. GitHub address is flask
The usage is very similar to bottle and is interesting to refer to Bottle-python's lightweight HTTP server.
#-*-Coding:utf-8-*-#!/usr/bin/python fromFlaskImportFlask, Jsonifyapp = Flask (__name__)@app. Route ('/') def index(): return ' index '#使用 <user> Pass Parameters@app. Route ('/hello/<user> ') def hello_get(user): return ' Hello get%s '% User#使用POST请求@app. Route ('/hello/<user> ', methods=[' POST ') def hello_post(user): return ' Hello post%s '% User@app. Route ('/hotcity ') def hotcity():Cities = [' Beijing ',' Shanghai ',' Guangzhou ']returnJsonify ({' Code ':0,' Cities ': Cities,})if__name__ = =' __main__ ': App.run ()#还可以浏览器调试# App.run (debug=true)
Unlike Django, flask can do code modifications without restarting the HTTP Server.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Flask---Another lightweight web framework for Python