Skip to content

Commit 82d2232

Browse files
committed
Subclass app to fix typing error
I've subclassed FastAPI to make it easier to attch LabThings error info to the fallback server.
1 parent 84716f1 commit 82d2232

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/labthings_fastapi/server/fallback.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
from fastapi.responses import HTMLResponse
44
from starlette.responses import RedirectResponse
55

6-
app = FastAPI()
6+
7+
class FallbackApp(FastAPI):
8+
def __init__(self, *args, **kwargs):
9+
super().__init__(*args, **kwargs)
10+
self.labthings_config = None
11+
self.labthings_server = None
12+
self.labthings_error = None
13+
14+
15+
app = FallbackApp()
716

817
ERROR_PAGE = """
918
<!DOCTYPE html>
@@ -27,10 +36,6 @@
2736
</html>
2837
"""
2938

30-
app.labthings_config = None
31-
app.labthings_server = None
32-
app.labthings_error = None
33-
3439

3540
@app.get("/")
3641
async def root():

0 commit comments

Comments
 (0)