larxius commited on
Commit
2b80190
·
verified ·
1 Parent(s): 3307b1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -23,12 +23,28 @@ from flask import send_from_directory, abort
23
  FRONTEND_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'frontend', 'dist')
24
 
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  @app.route('/', defaults={'path': ''})
27
  @app.route('/<path:path>')
28
  def serve_react(path):
29
  """Serve React SPA. Static assets go to dist/, everything else → index.html."""
30
- # Never intercept API, uploads, or socket.io requests
31
- if path.startswith('api/') or path.startswith('uploads/') or path.startswith('socket.io'):
32
  abort(404)
33
  if path and os.path.exists(os.path.join(FRONTEND_DIR, path)):
34
  res = send_from_directory(FRONTEND_DIR, path)
 
23
  FRONTEND_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'frontend', 'dist')
24
 
25
 
26
+ @app.route('/uploads/<path:filename>')
27
+ def serve_root_uploads(filename):
28
+ """Serve uploaded logos and static media files directly from uploads directory."""
29
+ uploads_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'uploads')
30
+ file_path = os.path.join(uploads_dir, filename)
31
+ if os.path.exists(file_path):
32
+ return send_from_directory(uploads_dir, filename)
33
+
34
+ # Check inside uploads/logos subfolder if requested without 'logos/' prefix
35
+ logos_dir = os.path.join(uploads_dir, 'logos')
36
+ if os.path.exists(os.path.join(logos_dir, filename)):
37
+ return send_from_directory(logos_dir, filename)
38
+
39
+ abort(404)
40
+
41
+
42
  @app.route('/', defaults={'path': ''})
43
  @app.route('/<path:path>')
44
  def serve_react(path):
45
  """Serve React SPA. Static assets go to dist/, everything else → index.html."""
46
+ # Never intercept API or socket.io requests
47
+ if path.startswith('api/') or path.startswith('socket.io'):
48
  abort(404)
49
  if path and os.path.exists(os.path.join(FRONTEND_DIR, path)):
50
  res = send_from_directory(FRONTEND_DIR, path)