File tree 2 files changed +19
-4
lines changed
2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1
1
from flask import Flask
2
2
3
- app = Flask (__name__ , static_folder = '../build' , template_folder = '../build' )
3
+ BUILD_DIR = 'build'
4
+ build_path = '../{}' .format (BUILD_DIR )
5
+
6
+ app = Flask (__name__ , static_folder = build_path )
7
+
4
8
import services .static
5
9
import services .views
6
10
Original file line number Diff line number Diff line change 1
- from services import app
2
- from flask import Flask , render_template
1
+ from services import app , BUILD_DIR
2
+ from flask import Flask , Response
3
+ from werkzeug .datastructures import Headers
4
+
5
+ def load_index_file ():
6
+ index_file_path = '{}/index.html' .format (BUILD_DIR )
7
+ with open (index_file_path , 'r' , encoding = 'utf-8' ) as f :
8
+ index_file = f .read ()
9
+ return index_file
10
+
11
+ app .config ['SEND_FILE_MAX_AGE_DEFAULT' ] = 31536000
12
+ index_file = load_index_file ()
3
13
4
14
@app .route ('/' , methods = ['GET' ])
5
15
def index ():
6
- return render_template ('index.html' )
16
+ return Response (index_file , mimetype = 'text/html' ,
17
+ headers = Headers ({'Cache-Control' : 'max-age=60' }))
7
18
8
19
@app .route ('/<path:path>' )
9
20
def static_file (path ):
You can’t perform that action at this time.
0 commit comments