souljoy commited on
Commit
71c2aee
·
1 Parent(s): 1dc057e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -1,16 +1,9 @@
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.post("/hello")
14
- def hello():
15
- return {"hello": "world"}
16
-
 
1
+ from flask import Flask, request
2
+ # ...
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