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()
def make_app(): app.register_blueprint(user_api.user_blue, url_prefix='/user') app.register_blueprint(category_api.blue, url_prefix='/category') CORS(app) return app
def make_app(): app.register_blueprint(info_api.info_blue, url_prefix='/info') app.register_blueprint(features_api.features_tools, url_prefix="/bank") app.register_blueprint(login_api.user_blue, url_prefix='/user') app.register_blueprint(icon_api.ico, url_prefix='/ico') app.register_blueprint(my_account.acc_blue, url_prefix="/account") app.register_blueprint(product_api.product_info, url_prefix='/products') app.register_blueprint(risk_level_api.risk_level, url_prefix='/question') app.register_blueprint(portrait_api.portrait_blue, url_prefix='/portrait') app.register_blueprint(user_vip_api.user_vip_blue, url_prefix="/uservip") app.register_blueprint(account_money_api.account_blue, url_prefix="") app.register_blueprint(phone_payment_api.phone_payment_blue, url_prefix="") app.register_blueprint(user_banlance_api.balance_blue, url_prefix="") CORS(app) return app
def make_app(): app.register_blueprint(function_api.user_function_blue, url_prefix='/api') app.register_blueprint(user_api.user_blue, url_prefix='/api/user') app.register_blueprint(name_test_api.test_blue, url_prefix='/api/name') app.register_blueprint(gift_api.gift_blue, url_prefix='/api/live') app.register_blueprint(change_password_api.change_blue, url_prefix='/api/change') app.register_blueprint(attention_api.my_blue, url_prefix='/api/Attention/') app.register_blueprint(intereted_api.feel_blue, url_prefix='/api/feel') app.register_blueprint(bang_api.my_blueindex, url_prefix='/api/Total/') app.register_blueprint(bang_api.my_blue1, url_prefix='/api/Bang/') CORS(app) return app
from mainapp import app from flask_script import Manager, Server from flask_cors import CORS from flask import url_for, redirect, session from mainapp.views import user, article, comment @app.route("/", methods=['GET']) def index(): return redirect(url_for('userBlue.index')) # 已脚本的方式启动 if __name__ == '__main__': # 解决跨域问题 CORS(app, resources={r"/*": {"origins": "*"}}, supports_credentials=True) app.register_blueprint(user.blue, url_prefix='/user') app.register_blueprint(article.blue, url_prefix='/article') app.register_blueprint(comment.blue, url_prefix='/comment') manager = Manager(app) # 启动debug模式 manager.add_command("runserver", Server(use_debugger=True)) manager.run() # 启动命令:跟django框架启动命令差不多 # python xxx.py runserver -h host -p port
def make_app(): app.register_blueprint(user_api.user_blue, url_prefix='/user') app.register_blueprint(goods_api.goods_blue, url_prefix='/goods') app.register_blueprint(home_api.home_blue, url_prefix='/home') app.register_blueprint(shopcar_api.shopcar_blue, url_prefix='/cart') app.register_blueprint(doctor_api.doctors_blue, url_prefix='/doctor') app.register_blueprint(forum_api.forum_blue, url_prefix='/forum') CORS(app) return app