def create_app(): my_app = Flask(__name__) my_app.config.from_pyfile('conf.py') models.init_app(my_app) services.init_app(my_app) routes.init_app(my_app) return my_app
def create_app(): app = Flask(__name__) app.config.from_envvar('REPORTS_CONFIG') app.config["MSG_MANAGER"] = MessageManager() routes.init_app(app) return app
def init_app(app): with app.app_context(): config.init_app(app) models.init_app(app) routes.init_app(app) services.init_app(app) # -- <testing user> ----------------------------------------------- admin_user = services.user_service.getByUsername('admin') if admin_user is None: services.user_service.insert('admin', 'admin') # -- </testing user> ---------------------------------------------- app.run(debug=True, port=3000)
def create_app(): app = Flask(__name__) app.config.from_envvar('REPORTS_CONFIG') @app.after_request def after_request(response): response.headers.add('Access-Control-Allow-Origin', '*') response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization') response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE') return response routes.init_app(app) return app
def create_app(): import models, routes, services, database app = Flask(__name__) app.config['SQLALCHEMY_TRACK_MODIFICARIONS'] = False app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database/upforgoodDB.sqlite3' app.config['SECRET_KEY'] = 'super-secret' CORS(app) #cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) models.init_app(app) routes.init_app(app) services.init_app(app) database.init_app(app) if __name__ == "__main__": app.run(debug=True) return app
def create_app(): app = Flask(__name__) models.init_app(app) routes.init_app(app) services.init_app(app) return app
#!/usr/bin/python3 # -*- coding:utf-8 -*- # Author:Linany from flask import Flask from config import Config import routes import static import models # 实例化配置 config = Config() # 创建Flash核心对象 app = Flask(__name__) # 创建数据库Sqlalchemy实例 db = models.init_app(app) # 绑定各模块到核心对象 static.init_app(app) routes.init_app(app) if __name__ == '__main__': APP_HOST = config.get("app_host") PORT = config.get("app_port") DEBUG = config.get("debug") app.run(host=APP_HOST, port=PORT, debug=DEBUG)
from flask import Flask, json from models import db import routes app = Flask(__name__) app.config.from_pyfile('config.py', silent=True) db.init_app(app) routes.init_app(app) @app.errorhandler(405) def not_allowed(error): return json.jsonify({'error': str(error)}), 405 @app.errorhandler(404) def not_found(error): return json.jsonify({'error': str(error)}), 404 @app.route('/api/') def api(): return '<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>' if __name__ == '__main__': app.run()