Moved API models to separate file
This commit is contained in:
parent
50e886f4d6
commit
db72c2a6e4
2 changed files with 11 additions and 10 deletions
|
@ -1,21 +1,12 @@
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
|
from rectes.models import Secret, SecretSaveResult
|
||||||
from rectes.redis_db import redis
|
from rectes.redis_db import redis
|
||||||
from rectes.utils import get_new_key
|
from rectes.utils import get_new_key
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
class Secret(BaseModel):
|
|
||||||
data: str
|
|
||||||
|
|
||||||
|
|
||||||
class SecretSaveResult(BaseModel):
|
|
||||||
status: str
|
|
||||||
retrieval_url: str
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/secret", response_model=SecretSaveResult)
|
@app.post("/secret", response_model=SecretSaveResult)
|
||||||
async def set_secret(data: Secret):
|
async def set_secret(data: Secret):
|
||||||
new_key = await get_new_key()
|
new_key = await get_new_key()
|
||||||
|
|
10
src/rectes/models.py
Normal file
10
src/rectes/models.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class Secret(BaseModel):
|
||||||
|
data: str
|
||||||
|
|
||||||
|
|
||||||
|
class SecretSaveResult(BaseModel):
|
||||||
|
status: str
|
||||||
|
retrieval_url: str
|
Loading…
Reference in a new issue