Skip to content

Commit

Permalink
feat: added timing middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
borolepratik committed Feb 12, 2024
1 parent a38a1a2 commit 364f29a
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 118 deletions.
6 changes: 6 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import json
import logging
from datetime import datetime
from typing import Annotated

import fastf1
from fastapi import FastAPI, HTTPException, Path, Query, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
from fastapi_utils.timing import add_timing_middleware
from fastf1.ergast import Ergast
from pandas import Timestamp

Expand All @@ -31,6 +33,9 @@
ergast = Ergast(result_type="raw", auto_cast=True)
favicon_path = "favicon.ico"

# Logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = FastAPI(
title="Slick Telemetry API",
Expand All @@ -56,6 +61,7 @@
allow_headers=["*"],
# HTTPSRedirectMiddleware # TODO use for production and staging
)
add_timing_middleware(app, record=logger.info, prefix="app")


@app.get("/favicon.ico", include_in_schema=False)
Expand Down
Loading

0 comments on commit 364f29a

Please sign in to comment.