mirror of
https://github.com/codl/forget
synced 2025-01-20 02:49:34 +01:00
proper config management
This commit is contained in:
parent
912674c3f4
commit
e7cfb44321
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/config.py
|
||||||
|
|
||||||
|
__pycache__
|
14
app.py
14
app.py
@ -4,11 +4,17 @@ from sqlalchemy import MetaData
|
|||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///forget'
|
|
||||||
app.config['SQLALCHEMY_ECHO'] = True
|
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
||||||
|
|
||||||
app.secret_key = 'hunter2'
|
default_config = {
|
||||||
|
"SQLALCHEMY_ECHO": True,
|
||||||
|
"SQLALCHEMY_TRACK_MODIFICATIONS": False,
|
||||||
|
"SQLALCHEMY_DATABASE_URI": "postgresql+psycopg2:///forget",
|
||||||
|
"SECRET_KEY": "hunter2"
|
||||||
|
}
|
||||||
|
|
||||||
|
app.config.update(default_config)
|
||||||
|
|
||||||
|
app.config.from_pyfile('config.py', True)
|
||||||
|
|
||||||
metadata = MetaData(naming_convention = {
|
metadata = MetaData(naming_convention = {
|
||||||
"ix": 'ix_%(column_0_label)s',
|
"ix": 'ix_%(column_0_label)s',
|
||||||
|
41
config.example.py
Normal file
41
config.example.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""
|
||||||
|
this is an example config file for Forget
|
||||||
|
|
||||||
|
copy this file to config.py before editing
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
DATABASE URI
|
||||||
|
|
||||||
|
determines where to connect to the database
|
||||||
|
see http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls for syntax
|
||||||
|
only postgresql with psycopg2 driver is officially supported
|
||||||
|
"""
|
||||||
|
SQLALCHEMY_DATABASE_URI='postgresql+psycopg2:///forget'
|
||||||
|
|
||||||
|
"""
|
||||||
|
SECRET KEY
|
||||||
|
|
||||||
|
this key is used to encrypt session cookies
|
||||||
|
you can generate a random key by running
|
||||||
|
openssl rand -base64 102 | tr -d "\n"; echo
|
||||||
|
or if you don't have openssl installed
|
||||||
|
cat /dev/random | head -c 102 | base64 | tr -d "\n"; echo
|
||||||
|
the latter might take a while if your system entropy is low, give it time
|
||||||
|
"""
|
||||||
|
SECRET_KEY='change me!'
|
||||||
|
|
||||||
|
"""
|
||||||
|
TWITTER CREDENTIALS
|
||||||
|
|
||||||
|
get these at apps.twitter.com
|
||||||
|
blah
|
||||||
|
"""
|
||||||
|
TWITTER_CONSUMER_KEY='vdsvdsvds'
|
||||||
|
TWITTER_CONSUMER_SECRET='hjklhjklhjkl'
|
||||||
|
|
||||||
|
"""
|
||||||
|
you can also use any config variable that flask expects here, such as
|
||||||
|
"""
|
||||||
|
# SESSION_COOKIE_SECURE=True
|
||||||
|
# DEBUG=True
|
@ -1,6 +1,6 @@
|
|||||||
{% if session %}
|
{% if session %}
|
||||||
Hello, {{session['display_name']}}! <a href="/logout">Log out</a>
|
<p>Hello, {{session['display_name']}}! <a href="/logout">Log out</a></p>
|
||||||
<code>{{session['created_at']}}</code>
|
<p><code>{{session}}</code></p>
|
||||||
{% else %}
|
{% else %}
|
||||||
Hello, stranger! <a href="/login/twitter">Log in with Twitter</a>
|
<p>Hello, stranger! <a href="/login/twitter">Log in with Twitter</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user