File size: 733 Bytes
dd85fb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
from typing import Any

import gradio as gr
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from .api.v1.detect import router as detect_router
from .gradio_demo.ui import build_demo


def create_app() -> FastAPI:
    app = FastAPI(title="FeatureLab Runtime", version="0.3.0")

    app.add_middleware(
        CORSMiddleware,
        allow_origins=["*"],
        allow_credentials=False,
        allow_methods=["*"],
        allow_headers=["*"],
    )

    app.include_router(detect_router)

    demo = build_demo()
    gr.mount_gradio_app(app, demo, path="/")

    @app.get("/health")
    async def healthcheck() -> Any:
        return {"status": "ok"}

    return app


app = create_app()