PythonMindset commited on
Commit
2f57958
·
1 Parent(s): e34cb44

Fix app.py: add static_url_path for proper static files serving

Browse files
Files changed (1) hide show
  1. app.py +3 -13
app.py CHANGED
@@ -1,29 +1,19 @@
1
- from flask import Flask, send_from_directory
2
  import os
3
 
4
  app = Flask(__name__,
5
  static_folder='static',
 
6
  template_folder='.')
7
 
8
- # DÉSACTIVER le cache pour les fichiers statiques
9
- app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
10
-
11
  @app.route('/')
12
  def index():
13
- response = send_from_directory('.', 'index.html')
14
- response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'
15
- return response
16
 
17
  @app.route('/test')
18
  def test():
19
  return send_from_directory('.', 'test.html')
20
 
21
- @app.route('/static/<path:path>')
22
- def serve_static(path):
23
- response = send_from_directory('static', path)
24
- response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'
25
- return response
26
-
27
  if __name__ == '__main__':
28
  port = int(os.environ.get('PORT', 7860))
29
  app.run(host='0.0.0.0', port=port, debug=False)
 
1
+ from flask import Flask, send_from_directory
2
  import os
3
 
4
  app = Flask(__name__,
5
  static_folder='static',
6
+ static_url_path='/static',
7
  template_folder='.')
8
 
 
 
 
9
  @app.route('/')
10
  def index():
11
+ return send_from_directory('.', 'index.html')
 
 
12
 
13
  @app.route('/test')
14
  def test():
15
  return send_from_directory('.', 'test.html')
16
 
 
 
 
 
 
 
17
  if __name__ == '__main__':
18
  port = int(os.environ.get('PORT', 7860))
19
  app.run(host='0.0.0.0', port=port, debug=False)