Configured to run behind reverse proxy, using Gunicorn
This commit is contained in:
parent
c7df4ad6dc
commit
f52d98333e
3 changed files with 9 additions and 3 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
From the root directory, run `pip install -r requirements.txt` to install the package (and all dependencies) in editable mode.
|
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
|
## Production
|
||||||
Run `python -m build --wheel` to generate the wheel, and install the wheel (found in `dist/`) in the production environment.
|
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
|
## 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**.
|
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**.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
|
|
||||||
def create_app(test_config=None):
|
def create_app(test_config=None):
|
||||||
# create and configure the app
|
# create and configure the app
|
||||||
|
|
@ -9,6 +10,10 @@ def create_app(test_config=None):
|
||||||
DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),
|
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:
|
if test_config is None:
|
||||||
# load the instance config, if it exists, when not testing
|
# load the instance config, if it exists, when not testing
|
||||||
app.config.from_pyfile('config.py', silent=True)
|
app.config.from_pyfile('config.py', silent=True)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ dnspython==2.3.0
|
||||||
email-validator==2.0.0.post2
|
email-validator==2.0.0.post2
|
||||||
exceptiongroup==1.1.1
|
exceptiongroup==1.1.1
|
||||||
Flask==2.3.2
|
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
|
h11==0.14.0
|
||||||
httpcore==0.17.0
|
httpcore==0.17.0
|
||||||
httptools==0.5.0
|
httptools==0.5.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue