@@ -66,8 +66,42 @@ async def healthz():
66
66
67
67
@self .quart_app .route ("/" )
68
68
async def index ():
69
- return await quart .send_from_directory (frontend_path , "index.html" )
69
+ return await quart .send_from_directory (
70
+ frontend_path ,
71
+ "index.html" ,
72
+ mimetype = "text/html"
73
+ )
70
74
71
75
@self .quart_app .route ("/<path:path>" )
72
76
async def static_file (path : str ):
73
- return await quart .send_from_directory (frontend_path , path )
77
+
78
+ mimetype = None
79
+
80
+ if path .endswith (".html" ):
81
+ mimetype = "text/html"
82
+ elif path .endswith (".js" ):
83
+ mimetype = "application/javascript"
84
+ elif path .endswith (".css" ):
85
+ mimetype = "text/css"
86
+ elif path .endswith (".png" ):
87
+ mimetype = "image/png"
88
+ elif path .endswith (".jpg" ):
89
+ mimetype = "image/jpeg"
90
+ elif path .endswith (".jpeg" ):
91
+ mimetype = "image/jpeg"
92
+ elif path .endswith (".gif" ):
93
+ mimetype = "image/gif"
94
+ elif path .endswith (".svg" ):
95
+ mimetype = "image/svg+xml"
96
+ elif path .endswith (".ico" ):
97
+ mimetype = "image/x-icon"
98
+ elif path .endswith (".json" ):
99
+ mimetype = "application/json"
100
+ elif path .endswith (".txt" ):
101
+ mimetype = "text/plain"
102
+
103
+ return await quart .send_from_directory (
104
+ frontend_path ,
105
+ path ,
106
+ mimetype = mimetype
107
+ )
0 commit comments