Base project
This commit is contained in:
parent
19a2d62a58
commit
5c9897958b
|
@ -0,0 +1,5 @@
|
|||
from envyaml import EnvYAML
|
||||
import os
|
||||
|
||||
def getConfig():
|
||||
return EnvYAML(os.getenv("CONFIG", "config.yaml"))
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
from typing import Annotated
|
||||
from fastapi import Header, HTTPException
|
||||
import config
|
||||
|
||||
async def get_token_header(x_token: Annotated[str, Header()]):
|
||||
if x_token != config.getConfig()["api-key"]
|
||||
raise HTTPException(status_code=400, detail="X-Token header is invalid")
|
|
@ -0,0 +1,8 @@
|
|||
from datetime import datetime, date
|
||||
from fastapi import FastAPI, HTTPException
|
||||
|
||||
from routers import recipe
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.include_router(recipe.router)
|
|
@ -0,0 +1,11 @@
|
|||
from fastapi import APIRouter, Depends, HTTPException
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/recipe",
|
||||
tags=["NLP"],
|
||||
responses={404: {"description": "Not found"}}
|
||||
)
|
||||
|
||||
@router.get("/")
|
||||
async def test():
|
||||
return "Hello world!"
|
Loading…
Reference in New Issue