Skip to content

Commit

Permalink
feat: 기본 셋팅
Browse files Browse the repository at this point in the history
  • Loading branch information
taewan2002 committed Feb 15, 2024
1 parent 9e7601d commit de1e76c
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ROOT_PATH=
SERVER_TYPE=local
ROOT_PATH=
DB_URL=localhost
4 changes: 3 additions & 1 deletion .env-prod
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ROOT_PATH=/api
SERVER_TYPE=prod
ROOT_PATH=/api
DB_URL=mysql-container
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /app

COPY main.py /app/
COPY app /app/app/
COPY .env-prod /app/.env
COPY requirements.txt /app/

RUN pip install --no-cache-dir -r requirements.txt
Expand Down
24 changes: 13 additions & 11 deletions app/core/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# from pydantic import BaseSettings
#
#
# class Settings(BaseSettings):
# ROOT_PATH: str
#
# class Config:
# env_file = ".env"
#
#
# settings = Settings()
from pydantic import BaseSettings


class Settings(BaseSettings):
SERVER_TYPE: str
ROOT_PATH: str
DB_URL: str

class Config:
env_file = ".env"


settings = Settings()
5 changes: 4 additions & 1 deletion app/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
from fastapi import HTTPException, status, Depends
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, Session

from app.core.config import settings
from app.db.models import get_Base, User
import aioredis
from fastapi.security import OAuth2PasswordBearer
from fastapi.security.api_key import APIKeyHeader
API_KEY_NAME = "Authorization"
api_key_header_auth = APIKeyHeader(name=API_KEY_NAME, auto_error=False)

DB_URL = f'mysql+pymysql://root:0000@localhost/sarabwayu'

DB_URL = f'mysql+pymysql://root:0000@{settings.DB_URL}/sarabwayu'
engine = create_engine(DB_URL, pool_recycle=3600)

Base = get_Base()
Expand Down
2 changes: 1 addition & 1 deletion app/service/house.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def recommendation(self):
"identity": "직장인",
"car": "차 없음",
"child": "아이 없음",
"significant": "유성구에 있는 아파트면 좋겠어"
"significant": "주변에 공원이 있었으면 좋겠어"
}
recommended_houses = house_recommender.recommend(persona)

Expand Down
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware

from app.core.config import settings
from app.router import auth, chat, house



app = FastAPI()
app = FastAPI(
root_path=settings.ROOT_PATH,
)

app.include_router(auth.router)
app.include_router(chat.router)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ passlib==1.7.4
bcrypt==4.0.1
scikit-learn==1.4.0
python-dotenv==1.0.0
requests==2.31.0
requests==2.31.0
urllib3==1.26.6

0 comments on commit de1e76c

Please sign in to comment.