8000 Add files via upload · django-myblog/web-with-fastapi@48776fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 48776fc

Browse files
authored
Add files via upload
1 parent 7c82e29 commit 48776fc

16 files changed

+208
-0
lines changed
685 Bytes
Binary file not shown.

ch05/planner/database/__init__.py

Whitespace-only changes.

ch05/planner/main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from fastapi import FastAPI
2+
from fastapi.responses import RedirectResponse
3+
4+
from routes.users import user_router
5+
from routes.events import event_router
6+
7+
import uvicorn
8+
9+
app = FastAPI()
10+
11+
# 라우트 등록
12+
13+
app.include_router(user_router, prefix="/user")
14+
app.include_router(event_router, prefix="/event")
15+
16+
17+
@app.get("/")
18+
async def home():
19+
return RedirectResponse(url="/event/")
20+
21+
if __name__ == '__main__':
22+
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)

ch05/planner/models/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.

ch05/planner/models/events.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from typing import List
2+
3+
from pydantic import BaseModel
4+
5+
6+
class Event(BaseModel):
7+
id: int
8+
title: str
9+
image: str
10+
description: str
11+
tags: List[str]
12+
location: str
13+
14+
class Config:
15+
schema_extra = {
16+
"example": {
17+
"title": "FastAPI Book Launch",
18+
"image": "https://linktomyimage.com/image.png",
19+
"description": "We will be discussing the contents of the FastAPI book in this event.Ensure to come with your own copy to win gifts!",
20+
"tags": ["python", "fastapi", "book", "launch"],
21+
"location": "Google Meet"
22+
}
23+
}

ch05/planner/models/users.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from pydantic import BaseModel, EmailStr
2+
from typing import Optional, List
3+
from models.events import Event
4+
5+
6+
7+
class User(BaseModel):
8+
email: EmailStr
9+
password: str
10+
events: Optional[List[Event]]
11 9E88 +
12+
13+
class Config:
14+
schema_extra = {
15+
"example": {
16+
"email": "fastapi@packt.com",
17+
"username": "strong!!!",
18+
"events": [],
19+
}
20+
}
21+
22+
23+
24+
25+
class UserSignIn(BaseModel):
26+
email: EmailStr
27+
password: str
28+
29+
class Config:
30+
schema_extra = {
31+
"example": {
32+
"email": "fastapi@packt.com",
33+
"password": "strong!!!",
34+
"events": [],
35+
}
36+
}

ch05/planner/requirements.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff lin EF4B e numberDiff line change
@@ -0,0 +1,32 @@
1+
anyio==3.5.0
2+
asgiref==3.5.0
3+
bcrypt==3.2.0
4+
beanie==1.10.4
5+
cffi==1.15.0
6+
click==8.0.4
7+
dnspython==2.2.0
8+
email-validator==1.1.3
9+
fastapi==0.74.1
10+
h11==0.13.0
11+
idna==3.3
12+
Jinja2==3.0.3
13+
MarkupSafe==2.1.0
14+
motor==2.5.1
15+
multidict==6.0.2
16+
passlib==1.7.4
17+
pycparser==2.21
18+
pydantic==1.9.0
19+
PyJWT==2.3.0
20+
pymongo==3.12.3
21+
python-dotenv==0.20.0
22+
python-multipart==0.0.5
23+
six==1.16.0
24+
sniffio==1.2.0
25+
SQLAlchemy==1.4.32
26+
sqlalchemy2-stubs==0.0.2a20
27+
sqlmodel==0.0.6
28+
starlette==0.17.1
29+
toml==0.10.2
30+
typing_extensions==4.1.1
31+
uvicorn==0.17.5
32+
yarl==1.7.2

0 commit comments

Comments
 (0)
0