souljoy commited on
Commit
1809ff7
1 Parent(s): 4d00c48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -1,9 +1,20 @@
1
- from flask import Flask, request
2
- app = Flask(__name__)
3
-
4
- @app.route('/json_example', methods=['POST'])
5
- def handle_json():
6
- data = request.json
7
- print(data.get('name'))
8
- print(data.get('age'))
9
- return data
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.responses import HTMLResponse
3
+
4
+ app = FastAPI()
5
+
6
+
7
+ @app.get("/")
8
+ def home():
9
+ html_content = open('index.html').read()
10
+ return HTMLResponse(content=html_content, status_code=200)
11
+
12
+
13
+ @app.get("/hello")
14
+ def hello():
15
+ return {"hello": "world"}
16
+
17
+
18
+ @app.get("/hello/{name}")
19
+ def greet(name):
20
+ return {"greeting": f"Hello {name}!"}