async def init_app() -> web.Application: app = web.Application() handler = ProgressionHandler() await init_workers(app, handler.queue, handler.task_list, 2) init_routes(app, handler) return app
def init_app(): """ Initialize application and depend module for it. Returns: app: instance of application """ app = web.Application() loop = asyncio.get_event_loop() db = loop.run_until_complete(init_db()) app['db'] = db client_uri = os.getenv('CLIENT_URI', '*') cors = aiohttp_cors.setup(app, defaults={ client_uri: aiohttp_cors.ResourceOptions( expose_headers='*', allow_headers='*', allow_credentials=True, allow_methods=['POST', 'GET', 'OPTIONS'], ), }) init_routes(app, cors) return app
def create_app(config_file): app = Flask(__name__) app.config.from_object(config_file) init_db(app) init_routes(app) CORS(app) return app
def init_app(argv=None) -> web.Application: app = web.Application() init_routes(app) dir_path = os.path.dirname(os.path.realpath(__file__)) aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader( os.path.join(dir_path, 'templates'))) return app
def init_app(app): #Database from repository import init_db init_db() #Rotas from routes import init_routes init_routes(app) app.run(host="0.0.0.0", port=3333)
def app_factory() -> web.Application: logging.basicConfig(level=logging.DEBUG) app = web.Application() init_routes(app) init_middleware(app) app.on_startup.extend([init_database]) app.on_cleanup.extend([close_database]) return app
def init_app(): #Database from repository import config_db app.db = config_db(app) from models import config_serializer config_serializer(app) app.db.create_all() #Rotas from routes import init_routes init_routes(app) app.run()
def create_app() -> Flask: app = Flask(__name__) app.config.from_object(Config) import error error.init_error(app) import log log.init_log(app) import routes routes.init_routes(app) if app.config['ENV'] == 'development': print(app.url_map) return app
async def app_init(): app = web.Application() init_db(app) aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('templates')) init_routes(app) return app
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from routes import init_routes from includes import init_includes from scans import init_scans PORT = 6543 engine = create_engine('mysql://*****:*****@localhost/cms', echo=True) Session = sessionmaker(bind=engine, expire_on_commit=False) Base = declarative_base() if __name__ == '__main__': app_session = SignedCookieSessionFactory('123321') with Configurator() as config: config.set_session_factory(app_session) init_routes(config) init_includes(config) init_scans(config) app = config.make_wsgi_app() print('web server running on port %d' % PORT) server = make_server('0.0.0.0', PORT, app) server.serve_forever()
#!/usr/bin/env python # coding=utf-8 from application import app from routes import init_routes if __name__ == '__main__': init_routes(app) app.run(debug=True, host='0.0.0.0')
from uuid import uuid4 from flask import Flask from blockchain import Blockchain from routes import init_routes app = Flask(__name__) blockchain = Blockchain() node_identifier = str(uuid4()).replace('-', '') init_routes(app, blockchain, node_identifier) app.run(host='0.0.0.0', port=5000)
import asyncpg # Sanic from sanic import Sanic # Custom routes import routes # import settings with open('./env.json', 'r') as f: config = json.loads(f.read()) app = Sanic() @app.listener('before_server_start') async def register_db(app, loop): app.app_config = config app.pool = await asyncpg.create_pool( database=config["database"]["database"], user=config["database"]["username"], password=config["database"]["password"], loop=loop, max_size=100) if __name__ == "__main__": # load all routes routes.init_routes(app) # Static files directory app.run(host="127.0.0.1", port=config["server"]["port"], debug=False)
def get_app(): init_routes() return app
from aiohttp import web from routes import setup_routes, init_routes from db import init_pg, close_pg from settings import config import aiohttp_cors app = web.Application() cors = aiohttp_cors.setup(app) init_routes(app, cors) setup_routes(app) app['config'] = config app.on_startup.append(init_pg) app.on_cleanup.append(close_pg) web.run_app(app, port=8085)