mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 16:50:02 +02:00
Merge pull request #115 from tiqi-group/feat/add_custom_css_default_response
feat: add "custom.css" endpoint default Response
This commit is contained in:
commit
ae68a89f48
@ -6,7 +6,7 @@ from typing import Any
|
|||||||
|
|
||||||
import socketio # type: ignore[import-untyped]
|
import socketio # type: ignore[import-untyped]
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI, Response
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
@ -171,12 +171,13 @@ class WebServer:
|
|||||||
return self.web_settings
|
return self.web_settings
|
||||||
|
|
||||||
# exposing custom.css file provided by user
|
# exposing custom.css file provided by user
|
||||||
if self.css is not None:
|
|
||||||
|
|
||||||
@app.get("/custom.css")
|
@app.get("/custom.css")
|
||||||
async def styles() -> FileResponse:
|
async def styles() -> Response:
|
||||||
|
if self.css is not None:
|
||||||
return FileResponse(str(self.css))
|
return FileResponse(str(self.css))
|
||||||
|
|
||||||
|
return Response(content="", media_type="text/css")
|
||||||
|
|
||||||
app.mount(
|
app.mount(
|
||||||
"/",
|
"/",
|
||||||
StaticFiles(
|
StaticFiles(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user