|
@@ -1,6 +1,5 @@
|
|
|
import asyncio
|
|
|
import os
|
|
|
-import platform
|
|
|
import time
|
|
|
import urllib.parse
|
|
|
from pathlib import Path
|
|
@@ -9,7 +8,6 @@ from typing import Dict, Optional
|
|
|
from fastapi import HTTPException, Request
|
|
|
from fastapi.middleware.gzip import GZipMiddleware
|
|
|
from fastapi.responses import FileResponse, Response
|
|
|
-from fastapi.staticfiles import StaticFiles
|
|
|
from fastapi_socketio import SocketManager
|
|
|
|
|
|
from nicegui import json
|
|
@@ -30,11 +28,6 @@ socket_manager = SocketManager(app=app, mount_location='/_nicegui_ws/', json=jso
|
|
|
globals.sio = sio = app.sio
|
|
|
|
|
|
app.add_middleware(GZipMiddleware)
|
|
|
-static_files = StaticFiles(
|
|
|
- directory=Path(__file__).parent / 'static',
|
|
|
- follow_symlink=platform.system().lower() != 'windows'
|
|
|
-)
|
|
|
-app.mount(f'/_nicegui/{__version__}/static', static_files, name='static')
|
|
|
|
|
|
globals.index_client = Client(page('/'), shared=True).__enter__()
|
|
|
|
|
@@ -44,6 +37,16 @@ def index(request: Request) -> Response:
|
|
|
return globals.index_client.build_response(request)
|
|
|
|
|
|
|
|
|
+@app.get(f'/_nicegui/{__version__}' + '/static/{name}')
|
|
|
+def get_static(name: str):
|
|
|
+ return FileResponse(Path(__file__).parent / 'static' / name)
|
|
|
+
|
|
|
+
|
|
|
+@app.get(f'/_nicegui/{__version__}' + '/static/fonts/{name}')
|
|
|
+def get_static(name: str):
|
|
|
+ return FileResponse(Path(__file__).parent / 'static' / 'fonts' / name)
|
|
|
+
|
|
|
+
|
|
|
@app.get(f'/_nicegui/{__version__}' + '/dependencies/{id}/{name}')
|
|
|
def get_dependencies(id: int, name: str):
|
|
|
if id in js_dependencies and js_dependencies[id].path.exists() and js_dependencies[id].path.name == name:
|