From e6c759e47676c61ce73deebfc73db420649dbdfa Mon Sep 17 00:00:00 2001 From: azivner Date: Wed, 16 Aug 2017 20:48:40 -0400 Subject: [PATCH] https can be disabled --- config-sample.ini | 5 ++++- src/app.py | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config-sample.ini b/config-sample.ini index 1aff92477..c748cb6d6 100644 --- a/config-sample.ini +++ b/config-sample.ini @@ -2,11 +2,14 @@ documentPath=demo.ncdb [Security] -# run python generate-secret-key.py and paste the result below +# run "python generate-secret-key.py" and paste the result below flaskSecretKey= [Network] port=5000 +# true for TLS/SSL/HTTPS (secure), false for HTTP (unsecure). +https=true +# path to certificate (run "bash generate-cert.sh" to generate self-signed certificate). Relevant only if https=true certPath=cert.crt certKeyPath=cert.key diff --git a/src/app.py b/src/app.py index 2ffb58dbd..781cbe4be 100644 --- a/src/app.py +++ b/src/app.py @@ -45,6 +45,7 @@ user = User() user.id = config['Login']['username'] port = config['Network']['port'] +https = config['Network']['https'] certPath = config['Network']['certPath'] certKeyPath = config['Network']['certKeyPath'] @@ -96,4 +97,9 @@ def load_user(user_id): api.add_resource(Notes, '/notes/') if __name__ == "__main__": - app.run(host='0.0.0.0', port=port, ssl_context = (certPath, certKeyPath)) \ No newline at end of file + ssl_context = None + + if https == "true": + ssl_context = (certPath, certKeyPath) + + app.run(host='0.0.0.0', port=port, ssl_context = ssl_context) \ No newline at end of file