commit 74b68faac063a8fe00aac1bcc43b23e7c6faf2c7
parent 4e32e60fc646cc3139b5788c3367fa215879539b
Author: Oshgnacknak <osh@oshgnacknak.de>
Date: Tue, 25 Jun 2019 21:13:19 +0100
move config to separate file
Diffstat:
4 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,3 +1,3 @@
-# Byte-compiled / optimized / DLL files
+config.py
__pycache__/
*.py[cod]
diff --git a/config.py.dist b/config.py.dist
@@ -0,0 +1,11 @@
+
+# create your config here and safe as 'config.py'
+# 'SECRET_KEY' must be set. $ head -c 32 /dev/random | sha1sum
+# the rest is optional
+
+config = {
+ 'SECRET_KEY': 'some_good_key',
+ 'DEBUG': False,
+ 'HOST': '127.0.0.1',
+ 'POST': 5000
+}
diff --git a/run.py b/run.py
@@ -1,10 +1,13 @@
from smtl.app import app
+from config import config
import os
def main():
- port = int(os.environ.get('PORT', 5000))
- app.run(host='0.0.0.0', port=port, debug=True)
+ host = config.get('HOST', '127.0.0.1')
+ port = config.get('PORT', 5000)
+ debug = config.get('DEBUG', False)
+ app.run(host='0.0.0.0', port=port, debug=debug)
if __name__ == '__main__':
diff --git a/smtl/app.py b/smtl/app.py
@@ -1,6 +1,7 @@
from flask import Flask, request, render_template, flash, redirect
from smtl.signup_form import SignupForm
from smtl.meta import meta
+from config import config
import sys
@@ -11,7 +12,7 @@ def add_to_db(data):
# App config.
app = Flask(__name__)
app.config.from_object(__name__)
-app.config['SECRET_KEY'] = '7d441f27d441f27567d441f2b6176a'
+app.config['SECRET_KEY'] = config['SECRET_KEY']
@app.route('/signup', methods=['POST'])