def setUp(self): config = {'TESTING': True, 'WTF_CSRF_ENABLED': False} 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 runserver(port=5000, config=CONFIG): """Runs a development server.""" from gevent.wsgi import WSGIServer from werkzeug.serving import run_with_reloader from werkzeug.debug import DebuggedApplication port = int(port) app = create_app(config) @run_with_reloader def run_server(): print('start server at: 127.0.0.1:%s' % port) http_server = WSGIServer(('', port), DebuggedApplication(app)) http_server.serve_forever() run_server()
gevent.monkey.patch_all() import os import sys import argparse from flask_script import Manager, Command from june.app import create_app settings = os.path.abspath('./etc/settings.py') if not os.path.exists(settings): settings = os.path.abspath('./etc/dev_config.py') if 'JUNE_SETTINGS' not in os.environ: os.environ['JUNE_SETTINGS'] = settings app = create_app() from june.models import db app.db = db manager = Manager(app) @manager.command def runserver(port=5000, with_profile=False): """Runs a development server.""" from flask import send_from_directory from gevent.wsgi import WSGIServer from werkzeug.serving import run_with_reloader from werkzeug.debug import DebuggedApplication from werkzeug.contrib.profiler import ProfilerMiddleware
def createdb(config=CONFIG): """Create a database.""" from june.models import db create_app(config) db.create_all()
# coding: utf-8 import gevent.monkey gevent.monkey.patch_all() from flask.ext.script import Manager from june.app import create_app CONFIG = '_config/development.py' manager = Manager(create_app()) @manager.command def runserver(port=5000, config=CONFIG): """Runs a development server.""" from gevent.wsgi import WSGIServer from werkzeug.serving import run_with_reloader from werkzeug.debug import DebuggedApplication port = int(port) app = create_app(config) @run_with_reloader def run_server(): print('start server at: 127.0.0.1:%s' % port) http_server = WSGIServer(('', port), DebuggedApplication(app)) http_server.serve_forever() run_server()
# coding: utf-8 import gevent.monkey gevent.monkey.patch_all() import os from flask.ext.script import Manager from june.app import create_app CONFIG = os.path.abspath('./etc/dev_config.py') app = create_app(CONFIG) manager = Manager(app) @manager.command def runserver(port=5000, with_profile=False): """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('./data/profile.log', 'w') wsgi = ProfilerMiddleware(app, f) else: wsgi = DebuggedApplication(app)
# coding: utf-8 import gevent.monkey gevent.monkey.patch_all() import os import sys from flask.ext.script import Manager from june.app import create_app CONFIG = os.path.abspath('./etc/dev_config.py') app = create_app(CONFIG) manager = Manager(app) @manager.command def runserver(port=5000, with_profile=False): """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('./data/profile.log', 'w') wsgi = ProfilerMiddleware(app, f) else:
fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support cwd = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(cwd) settings = os.path.join(cwd, 'etc/settings.py') if not os.path.exists(settings): settings = os.path.join(cwd, 'etc/dev_config.py') if 'JUNE_SETTINGS' not in os.environ: os.environ['JUNE_SETTINGS'] = settings from june.app import create_app from june.models import db app = create_app() # set the database url config.set_main_option( 'sqlalchemy.url', app.config.get('SQLALCHEMY_DATABASE_URI') ) target_metadata = db.metadata # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") # ... etc. def run_migrations_offline(): """Run migrations in 'offline' mode.
from june.app import create_app application = create_app()
def setUp(self): app = create_app() self.db_fd, self.db_path = tempfile.mkstemp() app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///%s' % self.db_path app.config['TESTING'] = True self.app = app.test_client()
def setUp(self): self.app = create_app() self.client = self.app.test_client()