-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 전체적인 구조 수정 & 6기 Product Serving 강의 커리큘럼 맞춤 적용
- Loading branch information
Showing
140 changed files
with
27 additions
and
880,995 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 @@ | ||
|
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
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
27 changes: 14 additions & 13 deletions
27
...ing(fastapi)/examples/11_event_handler.py → ...-serving(fastapi)/examples/11_lifespan.py
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,31 +1,32 @@ | ||
from fastapi import FastAPI | ||
import uvicorn | ||
from contextlib import asynccontextmanager | ||
|
||
app = FastAPI() | ||
import uvicorn | ||
from fastapi import FastAPI | ||
from loguru import logger | ||
|
||
items = {} | ||
|
||
|
||
@app.on_event("startup") | ||
def startup_event(): | ||
print("Start Up Event") | ||
@asynccontextmanager | ||
async def lifespan(app: FastAPI): | ||
logger.info("Start Up Event") | ||
items["foo"] = {"name": "Fighters"} | ||
items["bar"] = {"name": "Tenders"} | ||
|
||
yield | ||
|
||
@app.on_event("shutdown") | ||
def shutdown_event(): | ||
print("Shutdown Event!") | ||
logger.info("Shutdown Event!") | ||
with open("log.txt", mode="a") as log: | ||
log.write("Application shutdown") | ||
|
||
|
||
app = FastAPI(lifespan=lifespan) | ||
|
||
|
||
@app.get("/items/{item_id}") | ||
def read_items(item_id: str): | ||
return items[item_id] | ||
|
||
|
||
if __name__ == '__main__': | ||
uvicorn.run(app, host="0.0.0.0", port=8000) | ||
|
||
|
||
if __name__ == "__main__": | ||
uvicorn.run(app, host="0.0.0.0", port=8000) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.