Add offline mode support to fx.get_rates()
This commit is contained in:
parent
19ef9c24ba
commit
5d88485c48
|
@ -85,7 +85,9 @@ def get_rates(config: flask.config.Config) -> dict[str, Decimal]:
|
||||||
delta = now - recent
|
delta = now - recent
|
||||||
|
|
||||||
full_path = os.path.join(fx_dir, recent_filename)
|
full_path = os.path.join(fx_dir, recent_filename)
|
||||||
if recent_filename.endswith(file_suffix) and delta < timedelta(hours=12):
|
if recent_filename.endswith(file_suffix) and (
|
||||||
|
delta < timedelta(hours=12) or config["OFFLINE_MODE"]
|
||||||
|
):
|
||||||
return read_cached_rates(full_path, currencies)
|
return read_cached_rates(full_path, currencies)
|
||||||
|
|
||||||
url = "http://api.exchangerate.host/live"
|
url = "http://api.exchangerate.host/live"
|
||||||
|
|
Loading…
Reference in a new issue