Skip to content

Commit

Permalink
feat: 전체적인 구조 수정 & 6기 Product Serving 강의 커리큘럼 맞춤 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
zzsza committed Jan 28, 2024
2 parents 5beb763 + 3094f38 commit 6d595f7
Show file tree
Hide file tree
Showing 3 changed files with 499 additions and 615 deletions.
9 changes: 4 additions & 5 deletions 02-online-serving(fastapi)/examples/11_lifespan.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
from contextlib import asynccontextmanager

import uvicorn
from fastapi import FastAPI
from loguru import logger
import uvicorn

items = {}


@asynccontextmanager
async def lifespan(app: FastAPI):
logger.info("Start Up Event")
print("Start Up Event")
items["foo"] = {"name": "Fighters"}
items["bar"] = {"name": "Tenders"}

yield

logger.info("Shutdown Event!")
print("Shutdown Event!")
with open("log.txt", mode="a") as log:
log.write("Application shutdown")

Expand All @@ -28,5 +27,5 @@ def read_items(item_id: str):
return items[item_id]


if __name__ == "__main__":
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=8000)
Loading

0 comments on commit 6d595f7

Please sign in to comment.