Spaces:
Sleeping
Sleeping
Commit
•
2d683a3
1
Parent(s):
c73e7bc
Update main.py
Browse files
main.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from fastapi import FastAPI, HTTPException, Body, Request
|
2 |
from pydantic import BaseModel
|
3 |
from fastapi.templating import Jinja2Templates
|
4 |
-
import os
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
@@ -12,7 +11,6 @@ class TextRequest(BaseModel):
|
|
12 |
# Подключаем шаблоны Jinja2
|
13 |
templates = Jinja2Templates(directory="templates")
|
14 |
|
15 |
-
|
16 |
# Главная страница с текстом "server is running"
|
17 |
@app.get("/")
|
18 |
async def read_root(request: Request):
|
@@ -20,7 +18,6 @@ async def read_root(request: Request):
|
|
20 |
|
21 |
# Определяем единственный POST endpoint
|
22 |
@app.post("/echo")
|
23 |
-
def echo_text(text_request: TextRequest
|
24 |
# Просто возвращаем поле text из запроса
|
25 |
return {"echoed_text": text_request.text}
|
26 |
-
|
|
|
1 |
from fastapi import FastAPI, HTTPException, Body, Request
|
2 |
from pydantic import BaseModel
|
3 |
from fastapi.templating import Jinja2Templates
|
|
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
|
|
11 |
# Подключаем шаблоны Jinja2
|
12 |
templates = Jinja2Templates(directory="templates")
|
13 |
|
|
|
14 |
# Главная страница с текстом "server is running"
|
15 |
@app.get("/")
|
16 |
async def read_root(request: Request):
|
|
|
18 |
|
19 |
# Определяем единственный POST endpoint
|
20 |
@app.post("/echo")
|
21 |
+
def echo_text(text_request: TextRequest):
|
22 |
# Просто возвращаем поле text из запроса
|
23 |
return {"echoed_text": text_request.text}
|
|