Skip to content

Commit 8070f15

Browse files
committed
Try sending both uncompressed file if compressed version not found
1 parent cea3c0b commit 8070f15

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

backend/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ def publish(self, event_name: str, payload: dict):
4444
sse_broadcaster = SSEBroadcaster()
4545
board.on_pin_update(lambda update: sse_broadcaster.publish('pins', update))
4646

47+
def try_send_file(path):
48+
try:
49+
return send_file(path, compressed=True, file_extension='.gz')
50+
except FileNotFoundError:
51+
return send_file(path)
52+
53+
4754
@app.route('/')
4855
async def index(request):
49-
return send_file('/static/index.html', compressed=True, file_extension='.gz')
56+
return try_send_file('/static/index.html')
5057

5158
@app.route('/assets/<path:path>')
5259
async def asset(request, path):
53-
return send_file('/static/assets/' + path, compressed=True, file_extension='.gz')
60+
return try_send_file('/static/assets/' + path)
5461

5562
@app.route('/api/config/write', methods=['POST'])
5663
async def write_config(request):

0 commit comments

Comments
 (0)