2-3第一个flask程序
- virtualenv的使用
- 创建虚拟环境: virtualenv venv
- 激活虚拟环境: source venv/bin/activate
- 退出虚拟环境: deactivate
- flask的安装
- 安装前的检测: pip freeze
- 安装flask: pip install flask
- 安装后的检测: pip freeze
- mkvirtualenv flaskmovies
- workon flaskmovies
-
pip install flask
微信截图_20171214210751.png
3-1蓝图构建项目目录


RUN-1
- admin/init
from flask import Blueprint
admin = Blueprint("admin", __name__)
import app.admin.views
admin/views.py
from . import admin
@admin.route("/")
def index():
return "<h1 style='color:blue'>this is admin<h1
home/init
from flask import Blueprint
home = Blueprint("home", __name__)
import app.home.views
home/views.py
from . import home
@home.route("/")
def index():
return "<h1 style='color:green'>this is home<h1>"
- app/init
from flask import Flask
app = Flask(__name__)
app.debug = True
from app.home import home as home_blueprint
from app.admin import admin as admin_blueprint
app.register_blueprint(home_blueprint)
app.register_blueprint(admin_blueprint, url_prefix="/admin")
- manage.py
from app import app
if __name__ == '__main__':
app.run()
*运行


3-2 会员及会员登录日志数据模型设计

- pip install flask-sqlalchemy

网友评论