# -*-coding:utf-8 -*- from flask_script import Manager, Shell from livereload import Server from storage import create_app, db from storage.model import User from flask_migrate import Migrate, MigrateCommand # db参数 db_info = 'root:qq123456@localhost:3306' app = create_app(db_info) manager = Manager(app) migrate = Migrate(app, db) manager.add_command('db', MigrateCommand) @manager.command def dev(): server = Server(app.wsgi_app) server.watch('**/*.*') server.serve() def make_shell_context(): return dict(app=app, db=db, User=User) manager.add_command('shell', Shell(make_context=make_shell_context)) if __name__ == '__main__': manager.run()
class Config(object): DEBUG = True SECRET_KEY = 'ccc' SECRET_KEY_SALT = 'ssss' JSON_AS_ASCII = False PERMANENT_SESSION_LIFETIME = timedelta(days=3) PER_PAGE = 10 ADMIN_URL = '/admin/aaaaa' LOGIN_TOKEN_HEADER = 'Api-Key' LOGIN_TOKEN = 'api_key' MIDDLEWARE = ['storage.common.middleware.CommonMiddleware'] SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_DATABASE_URI = 'sqlite:///test.db' # SQLALCHEMY_ECHO = DEBUG UPLOAD_ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg']) UPLOAD_FOLDER_ROOT = os.path.dirname(os.path.abspath(__file__)) UPLOAD_FOLDER_PATH = 'images' UPLOAD_FOLDER = os.path.join(UPLOAD_FOLDER_ROOT, UPLOAD_FOLDER_PATH) app = create_app(Config()) app.wsgi_app = ProxyFix(app.wsgi_app) if __name__ == '__main__': app.run()