diff --git a/.gitignore b/.gitignore index 685b2cd..02292b4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ htmlcov/ dist/ build/ -*.egg-info/ \ No newline at end of file +*.egg-info/ + +config.py \ No newline at end of file diff --git a/tlapbot/__init__.py b/tlapbot/__init__.py index 0edf3ba..996f876 100644 --- a/tlapbot/__init__.py +++ b/tlapbot/__init__.py @@ -1,22 +1,11 @@ -import os +import os # for using paths in config from flask import Flask - def create_app(test_config=None): - # create and configure the app app = Flask(__name__, instance_relative_config=True) - app.config.from_mapping( - SECRET_KEY='dev', - DATABASE=os.path.join(app.instance_path, 'tlapbot.sqlite'), - ) - - if test_config is None: - # load the instance config, if it exists, when not testing - app.config.from_pyfile('config.py', silent=True) - else: - # load the test config if passed in - app.config.from_mapping(test_config) + app.config.from_object('tlapbot.default_config') + app.config.from_object('tlapbot.config') # ensure the instance folder exists try: diff --git a/tlapbot/default_config.py b/tlapbot/default_config.py new file mode 100644 index 0000000..2cb5bc2 --- /dev/null +++ b/tlapbot/default_config.py @@ -0,0 +1,3 @@ +SECRET_KEY='dev' +DATABASE='./instance/tlapbot.sqlite' +OWNCAST_ACCESS_TOKEN='' \ No newline at end of file diff --git a/tlapbot/owncastWebhooks.py b/tlapbot/owncastWebhooks.py index 7108629..776d46a 100644 --- a/tlapbot/owncastWebhooks.py +++ b/tlapbot/owncastWebhooks.py @@ -1,4 +1,4 @@ -from flask import Flask,request,json,g,Blueprint +from flask import Flask,request,json,g,Blueprint,current_app from sqlite3 import Error from tlapbot.db import get_db import requests @@ -37,7 +37,7 @@ def addUserToDatabase(user_id, db): def sendChat(message): # TODO: url to constant? url = 'http://localhost:8080/api/integrations/chat/send' - headers = {"Authorization": "Bearer " + OWNCAST_ACCESS_TOKEN} + headers = {"Authorization": "Bearer " + current_app.config['OWNCAST_ACCESS_TOKEN']} r = requests.post(url, headers=headers, json={"body": message}) return r.json()