-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
476 additions
and
2,153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import typing as t | ||
|
||
Routers = t.Set[t.Literal["codecheckr"] | t.Literal["instagram"] | t.Literal["xtra"]] | ||
Routers = t.Set[ | ||
t.Union[t.Literal["codecheckr"], t.Literal["instagram"], t.Literal["xtra"]] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from fastapi import APIRouter | ||
from fastapi_class import View | ||
|
||
|
||
@View(recogRouter := APIRouter(prefix="/facerecog", tags=["Face Recognition"])) | ||
class recogView: | ||
def get(self): | ||
return {"service": "not working"} | ||
|
||
|
||
router = APIRouter() | ||
router.include_router(recogRouter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
import time | ||
|
||
from asgi_correlation_id import CorrelationIdMiddleware | ||
from fastapi import FastAPI | ||
from fastapi import FastAPI, Request | ||
from fastapi.middleware.cors import CORSMiddleware | ||
from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware | ||
from fastapi_utils.timing import add_timing_middleware | ||
|
||
from .prefs import settings | ||
|
||
|
||
def configure_middlewares(app: FastAPI) -> None: | ||
add_timing_middleware(app, prefix="app") | ||
@app.middleware("http") | ||
async def add_process_time_header(request: Request, call_next): | ||
start_time = time.time() | ||
response = await call_next(request) | ||
process_time = time.time() - start_time | ||
response.headers["X-Process-Time"] = str(process_time) | ||
return response | ||
|
||
app.add_middleware(CorrelationIdMiddleware) | ||
|
||
add_cors_middleware(app) | ||
|
||
if settings.PRODUCTION: | ||
app.add_middleware(HTTPSRedirectMiddleware) | ||
|
||
|
||
def add_cors_middleware(app: FastAPI, /): | ||
app.add_middleware(CorrelationIdMiddleware) | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=settings.CORS_ORIGINS, | ||
allow_origins_regex=settings.CORS_REGEX_ORIGINS, | ||
allow_origin_regex=settings.CORS_REGEX_ORIGINS, | ||
allow_credentials=settings.CORS_ALLOW_CREDENTIALS, | ||
allow_methods=settings.CORS_ALLOW_METHODS, | ||
allow_headers=settings.CORS_ALLOW_HEADERS, | ||
expose_headers=["X-Request-ID"], | ||
expose_headers=["X-Request-ID", "X-Process-Time"], | ||
) |
Oops, something went wrong.