added loading config values from configfile
This commit is contained in:
parent
66acf10327
commit
4030454fa5
|
@ -1,3 +1,4 @@
|
|||
*.conf
|
||||
bottle.py
|
||||
__pycache__
|
||||
__pycache__/*
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
[cookies]
|
||||
cookie_secret='somesecretkey'
|
||||
cookie_max_age=1800 #seconds
|
||||
cookie_name='accounts'
|
||||
# accounts sample configfile
|
||||
# rename this file app.conf
|
||||
|
||||
[app]
|
||||
app_name='SocialNerds Accounts'
|
||||
static_files="/home/david/Git/accounts/static"
|
||||
[DEFAULT]
|
||||
cookie_secret=something secret like this 0TE5vYvF 0rDbjFIo ZHh28kmk 12jtcRW0
|
||||
cookie_max_age=1800
|
||||
cookie_name=accounts
|
||||
|
||||
[miab]
|
||||
miab_admin='someadmin@socialnerds.org'
|
||||
miab_passwd='xxxxx'
|
||||
miab_url='https://excelsior.socialnerds.org/admin'
|
||||
app_name=Accounts
|
||||
static_files=static
|
||||
|
||||
miab_admin=miabadmin@domain.tld
|
||||
miab_passwd=miabadminpassword
|
||||
miab_url=https://miaburl.domain.tld/admin
|
||||
|
||||
|
|
48
app.py
48
app.py
|
@ -1,10 +1,58 @@
|
|||
# imports
|
||||
|
||||
import requests
|
||||
from configparser import ConfigParser
|
||||
from bottle import route, run, template, error, get, \
|
||||
post, request, response, redirect, \
|
||||
static_file
|
||||
|
||||
|
||||
# config
|
||||
|
||||
configfile = "app.conf"
|
||||
config = ConfigParser()
|
||||
config.read(configfile)
|
||||
|
||||
if config['DEFAULT']['miab_admin']:
|
||||
miab_admin = config['DEFAULT']['miab_admin']
|
||||
else:
|
||||
miab_admin = "norealadmin@domain.ltd"
|
||||
|
||||
if config['DEFAULT']['miab_passwd']:
|
||||
miab_passwd = config['DEFAULT']['miab_passwd']
|
||||
else:
|
||||
miab_passwd = "norealpassword"
|
||||
|
||||
if config['DEFAULT']['miab_url']:
|
||||
miab_url = config['DEFAULT']['miab_url']
|
||||
else:
|
||||
miab_url = "https://norealmiab.domain.tld"
|
||||
|
||||
if config['DEFAULT']['app_name']:
|
||||
app_name = config['DEFAULT']['app_name']
|
||||
else:
|
||||
app_name = "Accounts"
|
||||
|
||||
if config['DEFAULT']['static_files']:
|
||||
static_files = config['DEFAULT']['static_files']
|
||||
else:
|
||||
static_files = "static"
|
||||
|
||||
if config['DEFAULT']['cookie_secret']:
|
||||
cookie_secret = config['DEFAULT']['cookie_secret']
|
||||
else:
|
||||
cookie_secret = "norealsecretDTR46SNI2390LGFsnDTRLASED2309h"
|
||||
|
||||
if config['DEFAULT']['cookie_max_age']:
|
||||
cookie_max_age = int(config['DEFAULT']['cookie_max_age'])
|
||||
else:
|
||||
cookie_max_age=1800
|
||||
|
||||
if config['DEFAULT']['cookie_name']:
|
||||
cookie_name = config['DEFAULT']['cookie_name']
|
||||
else:
|
||||
cookie_name = "accounts"
|
||||
|
||||
|
||||
# functions
|
||||
|
||||
|
|
Reference in New Issue