added config file

This commit is contained in:
coulisse 2020-01-22 16:24:20 +00:00
parent 77b1b251c9
commit 788f0b8e5d
3 changed files with 21 additions and 5 deletions

8
example_config.json Normal file
View File

@ -0,0 +1,8 @@
{
"mysql":{
"host":"localhost",
"user":"myusr",
"passwd":"mypwd",
"db":"dxcluster"
}
}

6
example_config.yml Normal file
View File

@ -0,0 +1,6 @@
mysql:
host: localhost
user: myuser
passwd: mypassword
db: dxcluster

View File

@ -5,16 +5,18 @@ import json
app = flask.Flask(__name__)
app.config["DEBUG"] = True
with open('config.json') as json_data_file:
cfg = json.load(json_data_file)
# A route to return all of the available entries in our catalog.
@app.route('/', methods=['GET'])
def spots():
db = my.connect(host='localhost',
user='webdb',
passwd='Zw73dp',
db='dxcluster'
db = my.connect(host=cfg['mysql']['host'],
user=cfg['mysql']['user'],
passwd=cfg['mysql']['passwd'],
db=cfg['mysql']['db']
)
cursor = db.cursor()
number_of_rows = cursor.execute('''SET NAMES 'utf8';''')
number_of_rows = cursor.execute('''SELECT rowid, spotter, freq, spotcall, comment, time from dxcluster.spot ORDER BY rowid desc limit 100;''')