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/
build/
*.egg-info/
config.py

View File

@ -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:

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 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()