mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 22:44:24 +01:00
improving get_config (#240)
This commit is contained in:
@@ -361,6 +361,18 @@ def delete_file(filename):
|
|||||||
|
|
||||||
@cache.memoize()
|
@cache.memoize()
|
||||||
def get_config(key):
|
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()
|
config = Config.query.filter_by(key=key).first()
|
||||||
if config and config.value:
|
if config and config.value:
|
||||||
value = config.value
|
value = config.value
|
||||||
|
|||||||
Reference in New Issue
Block a user