diff --git a/app/config.py b/app/config.py index a7cfb31..7d9803f 100644 --- a/app/config.py +++ b/app/config.py @@ -1,18 +1,18 @@ -# from pydantic import BaseSettings +from pydantic import BaseSettings -# class Settings(BaseSettings): -# database_hostname: str -# database_port: str -# database_password: str -# database_name: str -# database_username: str -# secret_key: str -# algorithm: str -# access_token_expire_minutes: int +class Settings(BaseSettings): + database_hostname: str + database_port: str + database_password: str + database_name: str + database_username: str + secret_key: str + algorithm: str + -# class Config: -# env_file = ".env" + class Config: + env_file = ".env" -# settings = Settings() \ No newline at end of file +settings = Settings() \ No newline at end of file diff --git a/app/database.py b/app/database.py index 4c7c881..f199abb 100644 --- a/app/database.py +++ b/app/database.py @@ -1,10 +1,12 @@ from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker +from .config import settings +SQLALCHEMY_DATABASE_URL = f'postgresql://{settings.database_username}:{settings.database_password}@{settings.database_hostname}:{settings.database_port}/{settings.database_name}' -SQLALCHEMY_DATABASE_URL = 'postgresql://postgres:abhishek1234@localhost/Sociome' +# engine=create_engine (SQLALCHEMY_DATABASE_URL) SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) diff --git a/app/oauth2.py b/app/oauth2.py index e21b6b3..db66a4d 100644 --- a/app/oauth2.py +++ b/app/oauth2.py @@ -4,16 +4,16 @@ from fastapi import Depends, status, HTTPException from fastapi.security import OAuth2PasswordBearer from sqlalchemy.orm import Session -# from .config import settings +from .config import settings oauth2_scheme = OAuth2PasswordBearer(tokenUrl='login') -SECRET_KEY= "535835638646865444444444444454545446446456464646467464567869767695468656464646764674646546467" -ALGORITHM="HS256" -# ACCESS_TOKEN_EXPIRE_MINUTES=30 +# SECRET_KEY= settings.secret_key +# ALGORITHM="HS256" +# # ACCESS_TOKEN_EXPIRE_MINUTES=30 -# SECRET_KEY = settings.secret_key -# ALGORITHM = settings.algorithm +SECRET_KEY = settings.secret_key +ALGORITHM = settings.algorithm # ACCESS_TOKEN_EXPIRE_MINUTES = settings.access_token_expire_minutes