def app(): db_fd, db_path = tempfile.mkstemp() app = create_app({ 'TESTING': True, 'DATABASE': db_path, }) with app.app_context(): init_db() get_db().executescript(_data_sql) yield app os.close(db_fd) os.unlink(db_path)
from FlaskApp import app as application application.secret_key = 'sajdsaddsdjadhaskjdsahdksahdjkadsada21321u787as8d9a' from FlaskApp import create_app application = create_app('production')
from FlaskApp import create_app app = create_app() if __name__ == '__main__': app.run(debug=True) # from flask import Flask, render_template # app = Flask(__name__) # @app.route('/') # @app.route('/home') # def home(): # return render_template('home.html', title='Home') # if __name__ == '__main__': # app.run(debug=True)
import os from FlaskApp import create_app, db from FlaskApp.models import User, Project from flask_script import Manager, Shell app = create_app('development') manager = Manager(app) def make_shell_context(): return dict(app=app, db=db, User=User, Project=Project) manager.add_command("shell", Shell(make_context=make_shell_context)) if __name__ == '__main__': manager.run()
def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all()
def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing
import os from FlaskApp import create_app, db from FlaskApp.models import User, Role from flask_script import Manager, Shell from flask_migrate import Migrate, MigrateCommand app = create_app(os.getenv('FLASK_CONFIG')) manager = Manager(app) migrate = Migrate(app,db) def make_shell_context(): return dict(app=app,db=db,User=User,Role=Role) manager.add_command("shell",Shell(make_context=make_shell_context)) manager.add_command('db',MigrateCommand) #migration command @manager.command def test(): """Run he unit tests.""" import unittest tests = unittest.TestLoader().discover('tests') unittest.TextTestRunner(verbosity=2).run(tests) if __name__ == "__main__": manager.run()#manager has no option like host & debug # app.run(host='0.0.0.0', debug=True)