summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoobry2019-10-24 14:08:48 +0200
committerdoobry2019-10-24 14:08:48 +0200
commit05d40216ee96649038f465ae2f28ac7ba28c5048 (patch)
tree0d81f5570c76c71277a5c7c4295f514b570b7b21
parentf544d94a8c903dcdc9f576af32958334b4a2a71c (diff)
Add support for external config files (Fixes: #33)v0.1.0
-rw-r--r--.gitignore1
-rw-r--r--README.md13
-rw-r--r--main.py1
3 files changed, 15 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index a09b786..e20d313 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
1__pycache__ 1__pycache__
2config.py
2custom_templates 3custom_templates
3uploads 4uploads
diff --git a/README.md b/README.md
index 202f307..a10f558 100644
--- a/README.md
+++ b/README.md
@@ -190,12 +190,25 @@ The `key` parameter is the key from a previously uploaded file.
190``` 190```
191 191
192# Docker 192# Docker
193
193There are two Dockerfiles present in this repository. The file called `Dockerfile.development` is used for development 194There are two Dockerfiles present in this repository. The file called `Dockerfile.development` is used for development
194and `Dockerfile.production` is used for production deployments. 195and `Dockerfile.production` is used for production deployments.
195 196
196You can find the automated docker builds in the registry of this 197You can find the automated docker builds in the registry of this
197repository: https://0xacab.org/jvoisin/mat2-web/container_registry 198repository: https://0xacab.org/jvoisin/mat2-web/container_registry
198 199
200# Configuration
201
202The default settings from `main.py` may be overridden by adding a `config.py`
203file and add custom values for the relevant flask config variables. E.g.:
204
205```
206MAX_CONTENT_LENGTH = 32 * 1024 * 1024 # 32MB
207```
208
209See [Flask configuration docs](http://exploreflask.com/en/latest/configuration.html)
210for further information.
211
199# Custom templates 212# Custom templates
200 213
201You can override the default templates from `templates/` by putting replacements 214You can override the default templates from `templates/` by putting replacements
diff --git a/main.py b/main.py
index 2309bf8..bd1a0c3 100644
--- a/main.py
+++ b/main.py
@@ -25,6 +25,7 @@ def create_app(test_config=None):
25 app.config['UPLOAD_FOLDER'] = './uploads/' 25 app.config['UPLOAD_FOLDER'] = './uploads/'
26 app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB 26 app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB
27 app.config['CUSTOM_TEMPLATES_DIR'] = 'custom_templates' 27 app.config['CUSTOM_TEMPLATES_DIR'] = 'custom_templates'
28 app.config.from_object('config') # optionally load settings from config.py
28 29
29 app.jinja_loader = jinja2.ChoiceLoader([ # type: ignore 30 app.jinja_loader = jinja2.ChoiceLoader([ # type: ignore
30 jinja2.FileSystemLoader(app.config['CUSTOM_TEMPLATES_DIR']), 31 jinja2.FileSystemLoader(app.config['CUSTOM_TEMPLATES_DIR']),