diasporadiaries

a platform for writing stories with personal accounts and messages
git clone git://parazyd.org/diasporadiaries.git
Log | Files | Refs | Submodules | README | LICENSE

commit d6196a159087d98e51efa182ee0d252def3b1659
parent c6d2a2f9c38a9ae3fe4a55711fc5cd6b2da59902
Author: parazyd <parazyd@dyne.org>
Date:   Tue, 22 Jan 2019 17:29:34 +0100

Add a configuration file to store variables.

Diffstat:
Aconfig.py | 25+++++++++++++++++++++++++
Mdb.py | 4+++-
Mdiaspora.py | 3++-
3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/config.py b/config.py @@ -0,0 +1,25 @@ +# Copyright (c) 2019 Ivan Jelincic <parazyd@dyne.org> +# +# This file is part of diasporadiaries +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +""" +Configuration file +""" + +# The secret key for flask-login. +SECRET_KEY = 'super-secret' + +# Path to the sqlite database. +DB_PATH = './stories.db' diff --git a/db.py b/db.py @@ -19,6 +19,8 @@ Module for sqlite database operations. """ from sqlite3 import connect +from config import DB_PATH + def initdb(dbpath): """ @@ -63,7 +65,7 @@ def initdb(dbpath): return _dbctx, _db -DBCTX, DB = initdb('./stories.db') +DBCTX, DB = initdb(DB_PATH) def sql_select_col_where(col0, col1, val, table='stories'): diff --git a/diaspora.py b/diaspora.py @@ -27,6 +27,7 @@ from flask import Markup, Flask, render_template, request, url_for, redirect from flask_login import (LoginManager, UserMixin, login_required, login_user, logout_user, current_user) +from config import SECRET_KEY from db import (sql_delete_row_where, sql_update_row_where, sql_insert, sql_select_col, sql_select_col_where) from utils import (get_story, makenav, randomstring, getcountryname, @@ -38,7 +39,7 @@ from utils import (get_story, makenav, randomstring, getcountryname, app = Flask(__name__) -app.config['SECRET_KEY'] = 'super-secret' +app.config['SECRET_KEY'] = SECRET_KEY app.add_template_global(makenav) login_manager = LoginManager()