Sunhey Cho commited on
Commit
89707b0
ยท
1 Parent(s): 24a402d

Add dedicated static file route handler to fix 404 errors for JS files

Browse files
Files changed (1) hide show
  1. api.py +5 -0
api.py CHANGED
@@ -1545,6 +1545,11 @@ def index_page():
1545
  print("Index route redirecting to index.html")
1546
  return redirect('/index.html')
1547
 
 
 
 
 
 
1548
  if __name__ == "__main__":
1549
  # ํ—ˆ๊น…ํŽ˜์ด์Šค Space์—์„œ๋Š” PORT ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค
1550
  port = int(os.environ.get("PORT", 7860))
 
1545
  print("Index route redirecting to index.html")
1546
  return redirect('/index.html')
1547
 
1548
+ @app.route('/static/<path:filename>')
1549
+ def static_files(filename):
1550
+ print(f"Serving static file: {filename}")
1551
+ return send_from_directory(app.static_folder, filename)
1552
+
1553
  if __name__ == "__main__":
1554
  # ํ—ˆ๊น…ํŽ˜์ด์Šค Space์—์„œ๋Š” PORT ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค
1555
  port = int(os.environ.get("PORT", 7860))