Skip to content
Snippets Groups Projects
app.py 918 B
Newer Older
  • Learn to ignore specific revisions
  • """Geomag Web Services
    
    This is an Application Server Gateway Interface (ASGI) application
    and can be run using uvicorn, or any other ASGI server:
    
        uvicorn geomagio.api:app
    
    from fastapi import FastAPI
    from starlette.responses import RedirectResponse
    
    from . import secure, ws
    
    LOG_BASIC_CONFIG = os.getenv("LOG_BASIC_CONFIG", "false")
    LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
    if LOG_BASIC_CONFIG == "true":
        logging.basicConfig(level=LOG_LEVEL)
    
    @asynccontextmanager
    async def lifespan(app: FastAPI):
        # on startup
    
    app = FastAPI(lifespan=lifespan)
    
    app.mount("/ws/secure", secure.app)
    app.mount("/ws", ws.app)
    
    @app.get("/", include_in_schema=False)
    async def redirect_to_ws():
        return RedirectResponse("/ws")