Base project

This commit is contained in:
Tyler Perkins 2023-08-12 23:01:11 -04:00
parent 19a2d62a58
commit 5c9897958b
7 changed files with 32 additions and 0 deletions

0
src/__init__.py Normal file
View File

5
src/config.py Normal file
View File

@ -0,0 +1,5 @@
from envyaml import EnvYAML
import os
def getConfig():
return EnvYAML(os.getenv("CONFIG", "config.yaml"))

1
src/config.yaml Normal file
View File

@ -0,0 +1 @@

7
src/dependencies.py Normal file
View File

@ -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")

8
src/main.py Normal file
View File

@ -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
src/routers/__init__.py Normal file
View File

11
src/routers/recipe.py Normal file
View File

@ -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!"