add a working config file!

This commit is contained in:
Lili (Tlapka) 2022-08-22 16:43:56 +02:00
parent fd28a7904a
commit ef88403ca4
4 changed files with 11 additions and 17 deletions

2
.gitignore vendored
View File

@ -10,3 +10,5 @@ htmlcov/
dist/ dist/
build/ build/
*.egg-info/ *.egg-info/
config.py

View File

@ -1,22 +1,11 @@
import os import os # for using paths in config
from flask import Flask from flask import Flask
def create_app(test_config=None): def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True) app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping( app.config.from_object('tlapbot.default_config')
SECRET_KEY='dev', app.config.from_object('tlapbot.config')
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)
# ensure the instance folder exists # ensure the instance folder exists
try: try:

View File

@ -0,0 +1,3 @@
SECRET_KEY='dev'
DATABASE='./instance/tlapbot.sqlite'
OWNCAST_ACCESS_TOKEN=''

View File

@ -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 sqlite3 import Error
from tlapbot.db import get_db from tlapbot.db import get_db
import requests import requests
@ -37,7 +37,7 @@ def addUserToDatabase(user_id, db):
def sendChat(message): # TODO: url to constant? def sendChat(message): # TODO: url to constant?
url = 'http://localhost:8080/api/integrations/chat/send' 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}) r = requests.post(url, headers=headers, json={"body": message})
return r.json() return r.json()