-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (27 loc) · 753 Bytes
/
main.py
File metadata and controls
33 lines (27 loc) · 753 Bytes
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
from fastapi import FastAPI
app = FastAPI()
#
@app.get('/')
def index():
return {'data': 'blog List'}
@app.get('/about') #adding about button
def about():
return {'about': 'about page'}
@app.get('/blog')
def index(limit=10, published:bool=True):
#return 'Hello Dear'
#return {'data': 'blog list'}
#return published
if published:
return {'data', f'{limit} published blogs from db'}
else :
return {'data', f'{limit} blogs from db'}
@app.get('/blog/unpublished')
def unpublished():
return {'data': 'all unpublished Blogs'}
@app.get('/blog/{id}')
def blog(id: int):
return {'data': id}
@app.get('/blog/{sd}/comments')
def comments(sd: int):
return { f'data {sd}' : {'comment1','comment2'}}