add redis storage
This commit is contained in:
parent
3392d8720f
commit
f2b7c63eee
@ -1,5 +1,7 @@
|
||||
from pymongo import MongoClient
|
||||
import os
|
||||
import os, redis
|
||||
|
||||
client = MongoClient("mongodb+srv://{0}:{1}@{2}/?retryWrites=true&w=majority&appName=AtlasApp".format(os.environ["MONGO_USER"], os.environ["MONGO_PASSWORD"], os.environ["MONGO_HOST"]))
|
||||
database = client[os.environ["MONGO_DATABASE"]]
|
||||
database = client[os.environ["MONGO_DATABASE"]]
|
||||
|
||||
connect_redis = redis.Redis(host=os.environ["REDIS_URL"], port=os.environ["REDIS_PORT"], decode_responses=True)
|
@ -8,7 +8,7 @@ router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/mail",tags=["mail"])
|
||||
async def read_users_me(userSingle: users.UserCreate | None = None):
|
||||
async def create_user(userSingle: users.UserCreate | None = None):
|
||||
if userSingle is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
@ -37,4 +37,5 @@ async def read_users_me(userSingle: users.UserCreate | None = None):
|
||||
await fm.send_message(message, template_name="mailer.html")
|
||||
current_user = users.User(username=userSingle.username, password=users_token.get_password_hash(userSingle.password), email=userSingle.email)
|
||||
user_repository.save(current_user)
|
||||
return JSONResponse(status_code=200, content={"message": "email has been sent"})
|
||||
database.connect_redis.set(userSingle.username, key_hashed)
|
||||
return JSONResponse(status_code=status.HTTP_200_OK, content={"message": "email has been sent"})
|
Loading…
x
Reference in New Issue
Block a user