add a working config file!
This commit is contained in:
		
							parent
							
								
									fd28a7904a
								
							
						
					
					
						commit
						ef88403ca4
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -10,3 +10,5 @@ htmlcov/
 | 
			
		||||
dist/
 | 
			
		||||
build/
 | 
			
		||||
*.egg-info/
 | 
			
		||||
 | 
			
		||||
config.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:
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								tlapbot/default_config.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tlapbot/default_config.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
SECRET_KEY='dev'
 | 
			
		||||
DATABASE='./instance/tlapbot.sqlite'
 | 
			
		||||
OWNCAST_ACCESS_TOKEN=''
 | 
			
		||||
@ -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()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user