flask回顾
pip install flask
from flask import Flask
app = Flask(__name__)
# 命令行启动,用manager,访问会变的非常慢
pip install flask_script
from flask_script import Manager
manager = Manager(app)
# 数据库迁移
pip install flask_migrate
from flask_migrate import Migrate,MigrateCommand
migrate = Migrate(app,db) # db是SQLAlchemy()对象
manager.add_command(“db”,MigrateCommand)
__init__.py
from flask improt Blueprint
index_blu = Blueprint(“index”,__name__)
from . import view
view.py
from . import index_blu
@index_blu.route(“/”)
def index():
return “hello” # {“msg”:1},jsonify(),redirct(“/news”),redirect(url_for(“index”)),render_template(“news/1.html”,data=data),make_response()
if __name__ == “__main__”:
manager.run(debug=True,host=”127.0.0.1:5000”)