flask Framework Quick Start

flask Framework Quick Start

Project to build a simple flask

  • The first to use Pycharm create flask project
  • Run flask project
1. Pycharm project to build a flask

(If the map does not appear Pycharm new project shown, you should upgrade to the latest version Pycharm)
New Project

2. Start project
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

 

Run app.run () simple flask project ran up, very simple

== rear end projects and logic interface is preferably separate ==

flask project design as much as possible as follows:

  1. views.py : interface logic
  2. logic.py : logic
  3. run.py : Application Published
4. Important Note

1. Getting started is really easy, now visit http://127.0.0.1:5000/ , you will see the Hello World, it represents a successful start.
2. Should closed, you can use Ctrl + C shut down the server, the end of the run

Guess you like

Origin www.cnblogs.com/Front-endGraph/p/11350319.html