2022-06-12 10:47:07 +00:00
|
|
|
from fastapi import FastAPI
|
2022-12-17 12:44:03 +00:00
|
|
|
|
2022-12-17 13:34:40 +00:00
|
|
|
from rectes.models import Secret, SecretSaveResult
|
2022-12-17 12:44:03 +00:00
|
|
|
from rectes.redis_db import redis
|
|
|
|
from rectes.utils import get_new_key
|
2022-06-12 10:47:07 +00:00
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
|
2022-12-17 13:33:26 +00:00
|
|
|
@app.post("/secret", response_model=SecretSaveResult)
|
2022-12-17 12:44:03 +00:00
|
|
|
async def set_secret(data: Secret):
|
|
|
|
new_key = await get_new_key()
|
|
|
|
await redis.setex(new_key, 60 * 60 * 24, data.data)
|
|
|
|
|
|
|
|
return {
|
|
|
|
"status": "saved",
|
|
|
|
"retrieval_url": f"/secret/{new_key}",
|
|
|
|
}
|