Three Flask Web Development Quick Start

Source: Internet
Author: User

1: Session:

 fromFlaskImportFlask, url_for, request, render_template, session fromWerkzeug.utilsImportRedirect, Escapeapp= Flask (__name__) @app. Route ('/')defindex ():if 'username' inchsession:return 'logged in as%s'% Escape (session['username'])    return 'You aren't logged in'@app. Route ('/login', methods=['GET','POST'])deflogin ():ifRequest.method = ='POST': session['username'] = request.form['username']        returnRedirect (Url_for ('Index'))    return " "<form action= "" method= "post" > <p><input type=text name=username> < P><input type=submit value=login> </form>" "@app. Route ('/logout')deflogout ():#Remove the username from the session if it ' s thereSession.pop ('username', None)returnRedirect (Url_for ('Index'))if __name__=='__main__': App.debug=True App.run ()

2: Deploy to a WEB server

Ready to deploy your Flask app? You can immediately deploy to a managed platform to successfully complete the QuickStart, and the following vendors offer free solutions to small projects:

    • Deploy Flask on Heroku
    • Specific instructions for deploying Flask attached Flask on DotCloud

Other options for managed Flask applications:

    • Deploy Flask on Webfaction
    • Deploy Flask on Google App Engine
    • Share your local server with Localtunnel

If you have your own hosting and are ready to host it yourself, see the Deployment Selection section.

Three Flask Web Development Quick Start

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.