diff --git a/README.md b/README.md index c8e668f..7ea53b3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ## Development From the root directory, run `pip install -r requirements.txt` to install the package (and all dependencies) in editable mode. -Use `flask --app flaskr run` to run app. The package will be updated as you edit files. +Use `gunicorn -w 2 'flaskr:create_app()'` to run app. Increase the number of workers using the `-w` argument if desired. The package will be updated as you edit files. ## Production Run `python -m build --wheel` to generate the wheel, and install the wheel (found in `dist/`) in the production environment. -Use `flask --app flaskr run` to run app. To update package, you will need to install a new wheel. +Use `gunicorn -w 2 'flaskr:create_app()'` to run app. Increase the number of workers using the `-w` argument if desired. To update package, you will need to install a new wheel. ## Initializing database The first time you install the app in each environment, you need to initialize database using `flask --app flaskr init-db`. This only needs to be run once per environment, and **will delete existing database if run again**. diff --git a/flaskr/__init__.py b/flaskr/__init__.py index bf080a1..ed7d989 100644 --- a/flaskr/__init__.py +++ b/flaskr/__init__.py @@ -1,5 +1,6 @@ import os from flask import Flask +from werkzeug.middleware.proxy_fix import ProxyFix def create_app(test_config=None): # create and configure the app @@ -9,6 +10,10 @@ def create_app(test_config=None): DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'), ) + app.wsgi_app = ProxyFix( + app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1 + ) + if test_config is None: # load the instance config, if it exists, when not testing app.config.from_pyfile('config.py', silent=True) diff --git a/requirements.txt b/requirements.txt index bd6b9c1..3f319fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,8 @@ dnspython==2.3.0 email-validator==2.0.0.post2 exceptiongroup==1.1.1 Flask==2.3.2 --e git+https://gitlab.com/pvtejas/based4tech.git@3518f50f67c913274f78e2c4b91fe9b7e052ac0d#egg=flaskr +-e git+https://gitlab.com/pvtejas/based4tech.git@4be89bd767a7c5a84ab62fbf4ad924ae1af077f1#egg=flaskr +gunicorn==20.1.0 h11==0.14.0 httpcore==0.17.0 httptools==0.5.0