def setUp(self): config = {'TESTING': True} config['SECRET_KEY'] = 'secret-key-for-test' 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() db.create_all() if hasattr(self, 'prehook'): self.prehook()
def setUp(self): config = {'TESTING': True} config['SECRET_KEY'] = 'secret-key-for-test' config['WWW_ROOT'] = 'tests/data' 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() db.create_all() if hasattr(self, 'prehook'): self.prehook()
import os import sys import gevent.monkey gevent.monkey.patch_all() from flask.ext.script import Manager from yuan.app import create_app from yuan.models import Project, Package from flask import json ROOTDIR = os.path.abspath(os.path.dirname(__file__)) CONF = os.path.join(ROOTDIR, 'etc/config.py') if not os.path.exists(CONF): CONF = os.path.join(ROOTDIR, 'conf/dev_config.py') app = create_app(CONF) manager = Manager(app) @manager.command def runserver(port=5000): """Runs a development server.""" from gevent.wsgi import WSGIServer from werkzeug.serving import run_with_reloader from werkzeug.debug import DebuggedApplication port = int(port) @run_with_reloader def run_server(): print('start server at: 127.0.0.1:%s' % port)
# coding: utf-8 import os import imp import gevent.monkey gevent.monkey.patch_all() from yuan.app import create_app import jieba jieba.initialize() application = create_app() ROOTDIR = os.path.abspath(os.path.dirname(__file__)) HOOK = os.path.join(ROOTDIR, 'etc/hook.py') if os.path.exists(HOOK): hook = imp.load_source('hook', HOOK) hook.main()
# coding: utf-8 import gevent.monkey gevent.monkey.patch_all() from yuan.app import create_app __all__ = ["app"] app = create_app()