File size: 1,061 Bytes
51c5186
 
 
 
 
 
 
 
 
 
 
6fc61f3
 
 
 
 
51c5186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dae9937
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
from fastapi import FastAPI, APIRouter, Request
from api.routes import router
import time
import logging

logging.basicConfig(
    level = logging.INFO,
    format = "%(asctime)s - %(levelname)s - %(message)s"
)

app = FastAPI(
    title="Vocal Fatigue Scoring API",
    version = "1.0",
    doc_url = "/doc",
    redoc_url = "/redoc",
    openapi_url="/openapi.json")


@app.middleware("HTTP")   
async def log_requests(request: Request, call_next):
    start = time.time()
    response = await call_next(request)
    duration = time.time() - start

    logging.info(
        f"{request.method} {request.url.path} "
        f"status_code = {response.status_code} "
        f"time = {duration:.3f}"
    )
    return response

api_v1 = APIRouter(prefix="/api/v1")
api_v1.include_router(router, prefix="/voice")

app.include_router(api_v1)

@app.get("/health")
def health():
    return {"status" : "ok"}  


@app.get("/")
def root():
    return {
        "name": "Auralis Vocal Fatigue Scoring API",
        "status": "running",
        "health": "/health"
    }