From 3675ed70c3bb5e279cf6b4ec4addfb2058ba7eac Mon Sep 17 00:00:00 2001 From: meeh Date: Sat, 20 Jul 2019 00:08:13 +0000 Subject: [PATCH] Enable hot-reload and development mode to make web changes less painful. --- runserver.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/runserver.py b/runserver.py index 2d1a4c9f..38ccb1e0 100755 --- a/runserver.py +++ b/runserver.py @@ -1,5 +1,19 @@ #!env/bin/python from i2p2www import app +import os + +# This code enable hot-reload of content and eliminates the +# need of restarting the server for changes in html files, +# most likely python files as well. +# To enable this, run with: +# DEV=whatever ./runserver.py +is_development = False +try: + os.environ['DEV'] + is_development = True +except KeyError: + pass + if __name__ == '__main__': - app.run(host='127.0.0.1', port=5000, debug=False) + app.run(host='127.0.0.1', port=5000, debug=is_development)