Flask --- another lightweight Web framework of Python

Source: Internet
Author: User

Flask --- another lightweight Web framework of Python

Flask is another lightweight Web framework in Python. on github, there are close to 15000 star. github addresses: Flask
Its usage is very similar to that of Bottle. If you are interested, refer to the lightweight http server of Bottle-Python.

#-*-Coding: UTF-8 -*-#! /Usr/bin/pythonfrom flask import Flask, jsonifyapp = Flask (_ name _) @ app. route ('/') def index (): return 'index' # Use

  
   
Pass the parameter @ app. route ('/hello/

   
    
') Def hello_get (user): return 'Hello get % s' % user # Use POST request @ app. route ('/hello/

    
     
', Methods = ['post']) def hello_post (user): return 'Hello POST % s' % user@app.route ('/hotCity ') def hotCity (): cities = ['beijing', 'shanghai', 'guangzhou '] return jsonify ({'code': 0, 'Cities': cities ,}) if _ name _ = '_ main _': app. run () # You can also debug in the browser # app. run (debug = True)

    

   

  

Unlike Django, Flask can modify code without restarting HTTP Server.

 

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.