def setUp(self): """Pre-test activities.""" config = {'TESTING': True} config['CSRF_ENABLED'] = False config['SECRET_KEY'] = 'secret-key-for-Qingblog-test' config['SQLALCHEMY_POOL_SIZE'] = 5 # Set up a temp-database each test case. self.db_fd, self.db_file = tempfile.mkstemp() config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///%s' % self.db_file app = create_app(config) self.app = app self.client = app.test_client() # Init the database db.create_all()
#!/usr/bin/env python # -*- coding: utf-8 -*- from Qingblog.app import create_app if __name__ == '__main__': create_app().run(port=5000)
# coding: utf-8 import gevent.monkey gevent.monkey.patch_all() import os import sys from flask.ext.script import Manager from Qingblog.app import create_app ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) LOG_FILE = os.path.join(ROOT_DIR, 'data', 'profile.log') app = create_app() manager = Manager(app) @manager.command def runserver(port=5000, with_profile=True): """Runs a development server.""" from gevent.wsgi import WSGIServer from werkzeug.serving import run_with_reloader from werkzeug.debug import DebuggedApplication from werkzeug.contrib.profiler import ProfilerMiddleware port = int(port) if with_profile: f = open(LOG_FILE, 'w') wsgi = ProfilerMiddleware(app, f) else: