-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd1b40e
commit b515f1a
Showing
5 changed files
with
98 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
from flask import Flask | ||
from cms import config | ||
|
||
|
||
def create_app(): | ||
app = Flask(__name__) | ||
def create_app(import_name): | ||
"""import_name tem que ser sempre a raiz do projeto | ||
onde está o cli.py, templates/ e static/""" | ||
|
||
# Faça o que quiser com o `app` aqui: | ||
app = Flask(import_name) | ||
|
||
# Iniciar o sistema de configurações dinâmicas | ||
config.configure(app) | ||
|
||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from dynaconf.contrib.flask_dynaconf import FlaskDynaconf | ||
|
||
|
||
def configure(app): | ||
"""Configure Dynaconf Flask Extension | ||
Dynaconf permite que variaveis sejam carregadas de diversas fontes | ||
e arquivos diferentes. | ||
Como arquivos yaml, ini, json, | ||
bancos de dados como Mongo ou Redis | ||
e variavéis de ambiente | ||
""" | ||
FlaskDynaconf( | ||
app=app, | ||
DYNACONF_NAMESPACE='CMS', | ||
SETTINGS_MODULE=f'{app.root_path}/settings.yml' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CMS: | ||
SECRET_KEY: 'real_secret_here' | ||
DB_NAME: cms_db | ||
SITENAME: Flask CMS | ||
HOST: '0.0.0.0' | ||
PORT: 5000 | ||
DEBUG: true | ||
RELOADER: true |