-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (46 loc) · 1.08 KB
/
main.py
File metadata and controls
63 lines (46 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Python
from uuid import UUID
from datetime import date, datetime
from typing import Optional
# Pydantic
from pydantic import BaseModel
from pydantic import EmailStr
from pydantic import Field
# FastAPI
from fastapi import FastAPI
app = FastAPI()
#Models
class UserBase(BaseModel):
user_id: UUID = Field(...)
email: EmailStr = Field(...)
class UserLogin(UserBase):
password: str = Field(
...,
min_length=8,
max_length=64,
)
class User(UserBase):
first_name: str = Field(
...,
min_length=1,
max_length=50,
)
last_name: str = Field(
...,
min_length=1,
max_length=50,
)
date_of_birth: Optional[date] = Field(default=None)
class Tweet(BaseModel):
tweet_id:UUID = Field(...)
content: str = Field(
...,
max_length=256,
min_length=1
)
created_at: datetime = Field(default=datetime.now())
update_at: Optional [datetime] = Field(default=None)
by: User = Field(...)
@app.get(path='/')
def home():
return {'Twitter API': 'Working' }