diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..173a626 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/config.py + +__pycache__ diff --git a/app.py b/app.py index 43dfdb3..e620572 100644 --- a/app.py +++ b/app.py @@ -4,11 +4,17 @@ from sqlalchemy import MetaData from flask_migrate import Migrate 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 = { "ix": 'ix_%(column_0_label)s', diff --git a/config.example.py b/config.example.py new file mode 100644 index 0000000..b68422a --- /dev/null +++ b/config.example.py @@ -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 diff --git a/templates/index.html b/templates/index.html index 70e148a..a2d1e00 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,6 +1,6 @@ {% if session %} - Hello, {{session['display_name']}}! Log out - {{session['created_at']}} +

Hello, {{session['display_name']}}! Log out

+

{{session}}

{% else %} - Hello, stranger! Log in with Twitter +

Hello, stranger! Log in with Twitter

{% endif %}