From db72c2a6e48c5e5c1acaa38415c7c61934060d50 Mon Sep 17 00:00:00 2001 From: Ivan Golikov Date: Sat, 17 Dec 2022 14:34:40 +0100 Subject: [PATCH] Moved API models to separate file --- src/rectes/main.py | 11 +---------- src/rectes/models.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 src/rectes/models.py diff --git a/src/rectes/main.py b/src/rectes/main.py index 0609776..5e23523 100644 --- a/src/rectes/main.py +++ b/src/rectes/main.py @@ -1,21 +1,12 @@ from fastapi import FastAPI -from pydantic import BaseModel +from rectes.models import Secret, SecretSaveResult from rectes.redis_db import redis from rectes.utils import get_new_key app = FastAPI() -class Secret(BaseModel): - data: str - - -class SecretSaveResult(BaseModel): - status: str - retrieval_url: str - - @app.post("/secret", response_model=SecretSaveResult) async def set_secret(data: Secret): new_key = await get_new_key() diff --git a/src/rectes/models.py b/src/rectes/models.py new file mode 100644 index 0000000..c51f16d --- /dev/null +++ b/src/rectes/models.py @@ -0,0 +1,10 @@ +from pydantic import BaseModel + + +class Secret(BaseModel): + data: str + + +class SecretSaveResult(BaseModel): + status: str + retrieval_url: str