foodiary ๐๐๐๐๐ญ
- ์์์ ๋จน๊ธฐ ์ ์ฌ์ง ํ์์ ํ๋ ์ฌ๋๋ค์ด ๋ง๋ค.
ํ์ง๋ง ์ด๋ ์ดฌ์ํ ์ฌ์ง์ ๋งค๋ฒ ๊ฒ์ํ๋ ๊ฒฝ์ฐ๋ ๋๋ฌผ๊ณ ์คํ ๋ฆฌ์ ์ฌ๋ฆฐ ์ฌ์ง์ ํ๋ฃจ๋ฉด ๋ด๋ ค๊ฐ๋ค.
๋ํ ๊ฐค๋ฌ๋ฆฌ ์ ๋ฆฌ์ ๋ถ์ง๋ฐํ์ง ์์ ์ฌ๋๋ค์ ๊ฐค๋ฌ๋ฆฌ์์ ๋ค์ ์ฐพ์๋ณด๊ธฐ๋ ํ๋ค๋ค.
์ธ์คํ๊ทธ๋จ๊ณผ ๊ฐ์ ์์
๊ธฐ๋ฅ์ด ๋ค์ด๊ฐ์ง ์์ ๊ธฐ๋ก์ฉ ์ฑ์ด ํ์ํ๋ค๊ณ ์๊ฐํ๋ค.
python3.10
- Framework : FastAPI
- Database : Mysql + Pymysql + Sqlalchemy + alembic
- OS : window
- ๋ก๊ทธ์ธ & ๋ก๊ทธ์์
- ์์ ์ฌ์ง ์ผ๊ธฐ์ฅ
- 2022-11-03 fast api project start
- 2022-11-04 JWT ํ ํฐ ์ฟ ํค๋ก ๋ฐ์์ค๋ ๋ฐฉ๋ฒ ์ฐพ๊ธฐ
- 2022-11-05 ์ฟ ํค์ ๋ด๊ณ , ๋ก๊ทธ์ธ ์ ์ง๊ฐ dependency ์ถ๊ฐ, refactoring
- 2022-11-16 post ๋ชจ๋ธ, ์คํค๋ง ์ถ๊ฐ
- 2022-11-17 post list, retrieve ์ถ๊ฐ
- 2022-11-22 food ์ด๋ฏธ์ง ์
๋ก๋ ๊ธฐ๋ฅ ์ถ๊ฐ + cors issue
- 2022-11-23 food ์ด๋ฏธ์ง ๊ธฐ๋ฅ post๋ก ์ด๋, ์ด๋ฏธ์ง ์
๋ก๋, ์ด๋ฏธ์ง response ์ถ๊ฐ
- 2022-11-24 food & post ๋ณํฉ, url ์์
CRUD |
HTTP |
URL |
ํ ํฐ ๋ฐํ |
POST |
/auth/token |
๋ก๊ทธ์ธ |
POST |
/auth/login |
๋ก๊ทธ์์ |
GET |
/auth/logout |
์ ์ ์กฐํ |
GET |
/auth/users |
์ ์ ์์ฑ |
POST |
/auth/users |
๋ด ์ ๋ณด ์กฐํ |
GET |
/auth/me |
CRUD |
HTTP |
URL |
๊ฒ์๊ธ ์ ์ฒด ์กฐํ |
GET |
/food |
๊ฒ์๊ธ ์์ฑ |
POST |
/food |
ํน์ ๊ฒ์๊ธ ์กฐํ |
GET |
/food/{food_id: int} |
์ด๋ฏธ์ง ๋ฑ๋ก |
POST |
/food/img |
๊ฒ์๊ธ ์ด๋ฏธ์ง ์กฐํ |
GET |
/food/img/{post_id: int} |
6.1 ๊ฒ์๊ธ ๋ฑ๋ก ์ํ์ค ๋ค์ด์ด๊ทธ๋จ
6.2 ๋ก๊ทธ์ธ ์ํ์ค ๋ค์ด์ด๊ทธ๋จ
- model ๋ณํ๋ฅผ Alembic์ผ๋ก DB์ ์ ์ฉ
8.1 ๊ฒ์๊ธ ๋ฑ๋ก ์ ์ด๋ฏธ์ง ์
๋ก๋ ๋ฌธ์
- PostBase ์คํค๋ง์ ์ด๋ฏธ์ง ํ์ผ๊ณผ ํ
์คํธ๋ฅผ ๋์์ ์
๋ ฅ ํ ๋์ ์ค๋ฅ ๋ฐ์
- ๊ฒ์๊ธ์ ๋ฑ๋ก ํ ๋์ title, description ์
๋ ฅ๊ณผ ์ด๋ฏธ์ง ๋ฑ๋ก ๋ถ๋ฆฌ
- url ์์ฒญ์ ํตํด ์ด๋ฏธ์ง ์
๋ก๋
@router.post("/img")
async def upload_img(request: Request, post_id: int, file: UploadFile, db: Session = Depends(get_db), dependencies=Depends(AuthProvider())):
contents = await file.read()
with open(os.path.join(IMG_URL, file.filename), "wb") as fp:
fp.write(contents)
return post_crud.update_img(request=request, db=db, post_id=post_id, img_url=file.filename)