-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
๋๋ต์ ์ธ ํด๋๊ตฌ์กฐ๋ฅผ ์์ฑํ์์ต๋๋ค.
- Loading branch information
Showing
7 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
repos: | ||
|
||
- repo: https://github.com/psf/black | ||
rev: '21.7b0' | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/PyCQA/pydocstyle | ||
rev: 6.1.1 | ||
hooks: | ||
- id: pydocstyle | ||
|
||
|
||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
|
||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
from dotenv import load_dotenv | ||
|
||
|
||
def connect(db): | ||
|
||
load_dotenv(verbose=True) | ||
|
||
POSTGRES_USER = os.getenv("POSTGRES_USER") | ||
POSTGRES_PASSWORD = os.getenv("POSTGRES_PASSWORD") | ||
POSTGRES_PORT = os.getenv("POSTGRES_PORT") | ||
POSTGRES_SERVER = os.getenv("POSTGRES_SERVER") | ||
POSTGRES_DB = db | ||
SQLALCHEMY_DATABASE_URL = f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}\ | ||
@{POSTGRES_SERVER}:{POSTGRES_PORT}/{POSTGRES_DB}" | ||
|
||
connection = create_engine(SQLALCHEMY_DATABASE_URL) | ||
|
||
return connection | ||
|
||
|
||
POSTGRES_DB = os.getenv("POSTGRES_DB") | ||
|
||
engine = connect(POSTGRES_DB) | ||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
Base = declarative_base() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from fastapi import APIRouter | ||
|
||
router = APIRouter( | ||
prefix="/predict", | ||
tags=["predict"], | ||
responses={404: {"description": "Not Found"}} | ||
) | ||
|
||
|
||
@router.get("/") | ||
def hello_world(): | ||
return {"message": "Hello predict"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from fastapi import FastAPI | ||
|
||
from app.router import predict | ||
from app.database import SessionLocal | ||
|
||
app = FastAPI() | ||
|
||
app.include_router(predict.router) | ||
|
||
|
||
def get_db(): | ||
db = SessionLocal() | ||
try: | ||
yield db | ||
finally: | ||
db.close() | ||
|
||
|
||
@app.get("/") | ||
def hello_world(): | ||
return {"message": "Hello World"} |