uvicorn integration
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@
|
|
| 8 |
|
| 9 |
from fastapi import FastAPI
|
| 10 |
from pydantic import BaseModel
|
|
|
|
| 11 |
|
| 12 |
app = FastAPI()
|
| 13 |
|
|
@@ -18,6 +19,8 @@ class NameRequest(BaseModel):
|
|
| 18 |
def greet(request: NameRequest):
|
| 19 |
return {"message": "Hello " + request.name + "!!"}
|
| 20 |
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# git add <filename>
|
| 23 |
# git commit -m <message>
|
|
@@ -32,5 +35,7 @@ def greet(request: NameRequest):
|
|
| 32 |
|
| 33 |
# https://cyrilfrl-test.hf.space/greet
|
| 34 |
|
|
|
|
|
|
|
| 35 |
# curl -X POST https://cyrilfrl-test.hf.space/greet -H "Content-Type: application/json" -d '{"name": "Cyril"}'
|
| 36 |
# curl -X POST "http://127.0.0.1:8000/greet" -H "Content-Type: application/json" -d "{\"name\": \"Cyril\"}"
|
|
|
|
| 8 |
|
| 9 |
from fastapi import FastAPI
|
| 10 |
from pydantic import BaseModel
|
| 11 |
+
import uvicorn
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
|
|
|
|
| 19 |
def greet(request: NameRequest):
|
| 20 |
return {"message": "Hello " + request.name + "!!"}
|
| 21 |
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 24 |
|
| 25 |
# git add <filename>
|
| 26 |
# git commit -m <message>
|
|
|
|
| 35 |
|
| 36 |
# https://cyrilfrl-test.hf.space/greet
|
| 37 |
|
| 38 |
+
# git commit conventions
|
| 39 |
+
|
| 40 |
# curl -X POST https://cyrilfrl-test.hf.space/greet -H "Content-Type: application/json" -d '{"name": "Cyril"}'
|
| 41 |
# curl -X POST "http://127.0.0.1:8000/greet" -H "Content-Type: application/json" -d "{\"name\": \"Cyril\"}"
|