def setUpClass(cls): '''Set up fixtures for the class. This methods runs once for the entire class. This test case do not insert or update any record on the database, so there is no problem to be run only once for the class. This way it save some time, instead of populate the test database each time a test is executed. ''' admin = create_admin() app = create_app(config='quokka.test_settings', DEBUG=False, test=True, admin_instance=admin) with app.app_context(): db = list(app.extensions.get('mongoengine').keys())[0] db.connection.drop_database('quokka_test') from quokka.utils.populate import Populate Populate(db)() cls.app = app cls.db = db
#!/usr/bin/env python # -*- coding: utf-8 -*- from flask.ext.script import Manager, Server from flask.ext.collect import Collect from quokka import create_app from quokka.core.db import db from quokka.ext.blueprints import load_blueprint_commands app = create_app() manager = Manager(app) manager.add_option("-c", "--config", dest="config", required=False, default='quokka.settings') collect = Collect() collect.init_script(manager) @manager.shell def make_shell_context(): " Update shell. " return dict(app=app, db=db) @manager.command def check(): """Prints app status""" from pprint import pprint print("Extensions.") pprint(app.extensions)
def app(): app = create_app(config='quokka.test_settings', DEBUG=False, test=True, mode='test') return app
see this post http://www.onurguzel.com/ how-to-run-flask-applications-with-nginx-using-gunicorn/ """ import argparse from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware from werkzeug.contrib.fixers import ProxyFix from quokka import create_app, create_api from quokka.utils.paas import activate # If running on PAAS such as OpenShift or heroku may require venv activation activate() application = DispatcherMiddleware(create_app(), {'/api': create_api()}) application.wsgi_app = ProxyFix(application.app.wsgi_app) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run Quokka App for WSGI") parser.add_argument('-p', '--port', help='App Port') parser.add_argument('-i', '--host', help='App Host') parser.add_argument('-r', '--reloader', action='store_true', help='Turn reloader on') parser.add_argument('-d', '--debug', action='store_true', help='Turn debug on')
import sys if len(sys.argv) > 1 and sys.argv[1] == "-r": reloader = True else: reloader = False from quokka import create_app app = create_app() app.run(use_reloader=reloader)
def create_app(self): self.admin = create_admin() return create_app(config='quokka.test_settings', DEBUG=False, test=True, admin_instance=self.admin)
def create_app(self): return create_app(config='quokka.test_settings', DEBUG=False, test=True)
#!/usr/bin/python import argparse from werkzeug.serving import run_simple from quokka import create_app application = app = create_app(ADMIN_REQUIRES_LOGIN=True) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run Quokka App for WSGI") parser.add_argument('-p', '--port', help='App Port') parser.add_argument('-i', '--host', help='App Host') parser.add_argument('-r', '--reloader', action='store_true', help='Turn reloader on') parser.add_argument('-d', '--debug', action='store_true', help='Turn debug on') args = parser.parse_args() run_simple( args.host or '127.0.0.1', int(args.port) if args.port else 5000, application, use_reloader=args.reloader or False, use_debugger=args.debug or False, )
def app(): """Flask Pytest uses it""" os.chdir('quokka/project_template/') return create_app()
# -*- coding: utf-8 -*- from werkzeug.serving import run_simple from werkzeug.contrib.fixers import ProxyFix from quokka import create_app application = create_app() application.wsgi_app = ProxyFix(application.wsgi_app) """ see this post http://www.onurguzel.com/ how-to-run-flask-applications-with-nginx-using-gunicorn/ """ if __name__ == "__main__": run_simple('0.0.0.0', 5000, application, use_reloader=True, use_debugger=True)
# -*- coding: utf-8 -*- from werkzeug.serving import run_simple from werkzeug.contrib.fixers import ProxyFix from quokka import create_app application = create_app() application.wsgi_app = ProxyFix(application.wsgi_app) """ see this post http://www.onurguzel.com/ how-to-run-flask-applications-with-nginx-using-gunicorn/ """ if __name__ == "__main__": run_simple( '0.0.0.0', 5000, application, use_reloader=True, use_debugger=True )
#!/usr/bin/python import argparse from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware from quokka import create_app, create_api from quokka.utils.paas import activate application = DispatcherMiddleware(create_app(), { '/api': create_api() }) application = app = activate(application) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run Quokka App for WSGI") parser.add_argument('-p', '--port', help='App Port') parser.add_argument('-i', '--host', help='App Host') parser.add_argument('-r', '--reloader', action='store_true', help='Turn reloader on') parser.add_argument('-d', '--debug', action='store_true', help='Turn debug on') args = parser.parse_args() run_simple( args.host or '0.0.0.0', int(args.port) if args.port else 5000, application, use_reloader=args.reloader or False, use_debugger=args.debug or False, )
#!/usr/bin/python """ see this post http://www.onurguzel.com/ how-to-run-flask-applications-with-nginx-using-gunicorn/ """ import argparse from werkzeug.serving import run_simple from werkzeug.wsgi import DispatcherMiddleware from werkzeug.contrib.fixers import ProxyFix from quokka import create_app, create_api from quokka.utils.paas import activate application = DispatcherMiddleware(create_app(), { '/api': create_api() }) application.wsgi_app = ProxyFix(application.app.wsgi_app) application = app = activate(application) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run Quokka App for WSGI") parser.add_argument('-p', '--port', help='App Port') parser.add_argument('-i', '--host', help='App Host') parser.add_argument('-r', '--reloader', action='store_true', help='Turn reloader on') parser.add_argument('-d', '--debug', action='store_true', help='Turn debug on')