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