Werkzeug Documentation: http://werkzeug.pocoo.org/documentation/ # Starting app in venu virtualenv venv . venv/bin/activate This file creates your application. """ from flask import Flask, render_template from models.user import User, db from models.helper.config import Config app = Flask(__name__) db.init_app(app) app.config['SQLALCHEMY_DATABASE_URI'] = Config.DB_ROUTE @app.route('/') def home(): # db.create_all() # admin = User('justin64', '*****@*****.**') # guest = User('paul123', '*****@*****.**') # db.session.add(admin) # db.session.add(guest) # db.session.commit() """Render website's home page.""" return render_template('home.html') @app.route('/new')
from mainapp import app from mainapp.views import user_v from flask_script import Manager # from models import db from models.user import db @app.route('/') def index(): return render_template("index.html") @app.route('/create_db') def create_database(): db.create_all() return "创建数据库中的所有模型表成功" @app.route('/drop_db') def drop_database(): db.drop_all() return "删除库中所有模型类对应的表" if __name__ == '__main__': app.register_blueprint(user_v.blue, url_prefix='/user') db.init_app(app) manage = Manager(app) manage.run()
from allFuncs import Funcs from models.user import db from models import config from werkzeug.routing import BaseConverter from utils import get_phone, auto, getNumber, get_uid from extension import login_manager from models.seat import Seat from features.shortMessage import send_message from features.test_welcome import welcome from routes.rtc import main as rtc_routes app = Flask(__name__) app.secret_key = 'test for good' app.config.from_object(config) db.init_app(app) # mysql数据库和app连接 login_manager.init_app(app) # login_manager模块和app连接 socketio.init_app(app) # 测试蓝图注册 app.register_blueprint(index_routes, url_prefix='') app.register_blueprint(binary_routes, url_prefix='') app.register_blueprint(login_routes, url_prefix='') app.register_blueprint(client_routes, url_prefix='') app.register_blueprint(account_routes, url_prefix='') app.register_blueprint(ccompany_routes, url_prefix='') app.register_blueprint(power_routes, url_prefix='') app.register_blueprint(rtc_routes, url_prefix='')