diff --git a/README.md b/README.md index 69f8a8c..3be3bf9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A simple shopping list app: -* Runs on gunicorn+flaskr (python) +* Runs on gunicorn+flask (python2.7) * Multi-user * Data saved as flat files, can contain markdown * Syntaxes parsed: @@ -10,24 +10,30 @@ A simple shopping list app: * [ ] and [x] tick boxes Note! Register page is enabled by default, but there is no link to it anywhere. -* Does not (yet) have proper configration file + +* Disable registering with env variable: `ENABLE_REGISTER=false` ## Running -To debug, run with `./debug.py` +- To debug, run with `./debug.py` -To run with gunicorn and nginx: +- To run with gunicorn and nginx: -start app: `gunicorn -b 0.0.0.0:8166 -w 2 shop:app` +- start app: `gunicorn -b 0.0.0.0:8000 -w 2 shop:app` -Add in nginx config: +- Add in nginx config: ``` location /myshop/ { - proxy_pass http://127.0.0.1:8166/; + proxy_pass http://127.0.0.1:8000/; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Scheme $scheme; proxy_set_header X-Script-Name /myshop; } ``` + + +- Register new user at page http://localhost:8000/register + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8268dc1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +gunicorn +flask diff --git a/run.example b/run.example new file mode 100755 index 0000000..67cb308 --- /dev/null +++ b/run.example @@ -0,0 +1,5 @@ +#!/bin/bash + +export SESSION_COOKIE_NAME=mdshop +#export ENABLE_REGISTER=false +exec gunicorn -b 127.0.0.1:8000 -w 2 shop:app diff --git a/shop.py b/shop.py index ee210a1..ca72023 100644 --- a/shop.py +++ b/shop.py @@ -22,6 +22,8 @@ CODEFINDER = re.compile(r'\`([^\`]+)\`') app = Flask(__name__) app.config.from_object(__name__) app.config['SESSION_COOKIE_NAME'] = os.getenv('SESSION_COOKIE_NAME', 'mdshop') +app.config['register'] = os.getenv('ENABLE_REGISTER', 'true') != 'false' +print(app.config) app.wsgi_app = ReverseProxied(app.wsgi_app) def connect_db(): @@ -463,6 +465,8 @@ def login(): @app.route('/register', methods=['GET', 'POST']) def register(): error = None + if not app.config['register']: + return "" if request.method == 'POST': import re, string pattern = re.compile('[\W]+')