Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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}!"}
|