|
@@ -27,6 +27,7 @@ from typing import (
|
|
from fastapi import FastAPI, HTTPException, Request, UploadFile
|
|
from fastapi import FastAPI, HTTPException, Request, UploadFile
|
|
from fastapi.middleware import cors
|
|
from fastapi.middleware import cors
|
|
from fastapi.responses import StreamingResponse
|
|
from fastapi.responses import StreamingResponse
|
|
|
|
+from fastapi.staticfiles import StaticFiles
|
|
from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn
|
|
from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn
|
|
from socketio import ASGIApp, AsyncNamespace, AsyncServer
|
|
from socketio import ASGIApp, AsyncNamespace, AsyncServer
|
|
from starlette_admin.contrib.sqla.admin import Admin
|
|
from starlette_admin.contrib.sqla.admin import Admin
|
|
@@ -46,7 +47,7 @@ from reflex.components.core.client_side_routing import (
|
|
Default404Page,
|
|
Default404Page,
|
|
wait_for_client_redirect,
|
|
wait_for_client_redirect,
|
|
)
|
|
)
|
|
-from reflex.components.core.upload import Upload
|
|
|
|
|
|
+from reflex.components.core.upload import Upload, get_uploaded_files_dir
|
|
from reflex.components.radix import themes
|
|
from reflex.components.radix import themes
|
|
from reflex.config import get_config
|
|
from reflex.config import get_config
|
|
from reflex.event import Event, EventHandler, EventSpec
|
|
from reflex.event import Event, EventHandler, EventSpec
|
|
@@ -252,6 +253,13 @@ class App(Base):
|
|
if Upload.is_used:
|
|
if Upload.is_used:
|
|
self.api.post(str(constants.Endpoint.UPLOAD))(upload(self))
|
|
self.api.post(str(constants.Endpoint.UPLOAD))(upload(self))
|
|
|
|
|
|
|
|
+ # To access uploaded files.
|
|
|
|
+ self.api.mount(
|
|
|
|
+ str(constants.Endpoint.UPLOAD),
|
|
|
|
+ StaticFiles(directory=get_uploaded_files_dir()),
|
|
|
|
+ name="uploaded_files",
|
|
|
|
+ )
|
|
|
|
+
|
|
def add_cors(self):
|
|
def add_cors(self):
|
|
"""Add CORS middleware to the app."""
|
|
"""Add CORS middleware to the app."""
|
|
self.api.add_middleware(
|
|
self.api.add_middleware(
|