Esempio n. 1
0
def setup_database_creation_listener(app: Sanic, database: Gino):

    database.init_app(app)

    @app.listener("after_server_start")
    async def setup_database(app: Sanic, loop):

        await database.gino.create_all()
Esempio n. 2
0
from sanic import Sanic
import asyncio
from sys import platform
from gino.ext.sanic import Gino
from config import *
from sanic_cors import CORS


app = Sanic("Heros legacy")
app.config.DB_HOST = DB_ARGS['host']
app.config.DB_DATABASE = DB_ARGS['database']
app.config.DB_PASSWORD = DB_ARGS['password']
app.config.DB_USER = DB_ARGS['user']
app.config.DB_PORT = DB_ARGS['port']
CORS(app, resources={r"/*": {"origins": "*"}})
db = Gino()
db.init_app(app)