mirror of https://github.com/JohnHammond/CTFd.git
improving get_config (#240)
parent
72f7eeb0a4
commit
b2fc5a6fcd
|
@ -361,6 +361,18 @@ def delete_file(filename):
|
|||
|
||||
@cache.memoize()
|
||||
def get_config(key):
|
||||
with app.app_context():
|
||||
value = app.config.get(key)
|
||||
if value:
|
||||
if value and value.isdigit():
|
||||
return int(value)
|
||||
elif value and isinstance(value, six.string_types):
|
||||
if value.lower() == 'true':
|
||||
return True
|
||||
elif value.lower() == 'false':
|
||||
return False
|
||||
else:
|
||||
return value
|
||||
config = Config.query.filter_by(key=key).first()
|
||||
if config and config.value:
|
||||
value = config.value
|
||||
|
|
Loading…
Reference in New Issue