-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (50 loc) · 1.15 KB
/
main.py
File metadata and controls
67 lines (50 loc) · 1.15 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
from fastapi import FastAPI
from pydantic import BaseModel
from typing import List
#trying to make a change
class Users(BaseModel):
name: str
age: int | None = None
email: str| None = None
password: str | None = None
active: bool | None = True
users = []
app = FastAPI(
title = 'FAST API LMS',
description = "learning Management System for students",
version = "0.0.1",
terms_of_service = "http://example.com/terms/",
contact={
"name": "Prince Owen",
"url" : 'https://www.linkedin.com/in/prince-owen-0b1a0a1a4/',
"email": "princeowen90@gmail.com" ,
},
license_info={
"name": "MIT License",
"url": "https://opensource.org/licenses/MIT",
},
tags_metadata=[
{
"name": "users",
"description": "users endpoints",
},
{
"name": "courses",
"description": "courses endpoints",
},
{
"name": "lessons",
"description": "lessons endpoints",
},
]
)
@app.get("/users", response_model=List[Users])
def get_users():
return users
@app.post("/users")
def create_user(user: Users) -> dict:
users.append(user.dict())
return {"User created": user.dict()}
@app.get("/users/{user_id}")
def get_user(user_id: int):
return users[user_id]