Flask---Another lightweight web framework for Python

Source: Internet
Author: User

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

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.