Spaces:
Runtime error
Runtime error
Revert "Update main.py"
Browse files- app/main.py +5 -6
app/main.py
CHANGED
@@ -4,8 +4,7 @@ import pathlib
|
|
4 |
import time
|
5 |
import re
|
6 |
from typing import List
|
7 |
-
from
|
8 |
-
from fastapi import FastAPI
|
9 |
from fastapi.middleware import Middleware
|
10 |
from fastapi.middleware.cors import CORSMiddleware
|
11 |
from fastapi.responses import StreamingResponse
|
@@ -54,12 +53,12 @@ async def process_input(text: str):
|
|
54 |
generator = re.split(r'(\s)', message)
|
55 |
return StreamingResponse(astreamer(generator), media_type='text/event-stream')
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
@app.post("/upload")
|
62 |
-
def upload(data
|
63 |
if data.get('bytes', None) and data.get('filename', None):
|
64 |
try:
|
65 |
filename = data['filename']
|
|
|
4 |
import time
|
5 |
import re
|
6 |
from typing import List
|
7 |
+
from fastapi import FastAPI, Request, Depends
|
|
|
8 |
from fastapi.middleware import Middleware
|
9 |
from fastapi.middleware.cors import CORSMiddleware
|
10 |
from fastapi.responses import StreamingResponse
|
|
|
53 |
generator = re.split(r'(\s)', message)
|
54 |
return StreamingResponse(astreamer(generator), media_type='text/event-stream')
|
55 |
|
56 |
+
async def parse_body(request: Request):
|
57 |
+
data = await request.json()
|
58 |
+
return data
|
59 |
|
60 |
@app.post("/upload")
|
61 |
+
def upload(data = Depends(parse_body)):
|
62 |
if data.get('bytes', None) and data.get('filename', None):
|
63 |
try:
|
64 |
filename = data['filename']
|