File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,21 @@ def error404():
281
281
), 404 )
282
282
283
283
284
+ # We are checking only the current domain subfolder and adding all the files to files_to_track array
285
+ # so that they can be tracked and on change of any of these files, reload the server in real time
286
+ def get_filenames_to_watch_and_reload ():
287
+ dir_to_look = "tutorials/" + current_domain
288
+ files_to_track = []
289
+
290
+ for dirname , dirs , files in os .walk (dir_to_look ):
291
+ for filename in files :
292
+ filename = os .path .join (dirname , filename )
293
+ if os .path .isfile (filename ):
294
+ files_to_track .append (filename )
295
+
296
+ return files_to_track
297
+
298
+
284
299
@app .route ("/favicon.ico" )
285
300
def favicon ():
286
301
return open (os .path .join (os .path .dirname (__file__ ), get_domain_data ()["favicon" ][1 :]), "rb" ).read ()
@@ -432,4 +447,6 @@ def robots():
432
447
433
448
if __name__ == "__main__" :
434
449
logging .info ("listening on port %s" , args .port )
435
- app .run (debug = True , port = args .port , host = args .host )
450
+
451
+ # The extra_files attribute enables us to provide file names which need to be tracked on change, trigger server reload
452
+ app .run (debug = True , port = args .port , host = args .host , extra_files = get_filenames_to_watch_and_reload ())
You can’t perform that action at this time.
0 commit comments