Add caching
This commit is contained in:
parent
3c4bbdbef0
commit
98a19a1ed8
9
wsgi.py
9
wsgi.py
@ -2,10 +2,18 @@ import datetime
|
||||
|
||||
import pandas as pd
|
||||
from flask import Flask, render_template, request
|
||||
from flask_caching import Cache
|
||||
|
||||
from download_digital import construct_dataframe, get_bez_data
|
||||
|
||||
config = {
|
||||
"CACHE_TYPE": "SimpleCache", # Flask-Caching related configs
|
||||
"CACHE_DEFAULT_TIMEOUT": 300,
|
||||
}
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_mapping(config)
|
||||
cache = Cache(app)
|
||||
|
||||
|
||||
def get_tables(url: str) -> tuple[pd.DataFrame, pd.DataFrame]:
|
||||
@ -25,6 +33,7 @@ def get_tables(url: str) -> tuple[pd.DataFrame, pd.DataFrame]:
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@cache.cached(timeout=50)
|
||||
def tables(
|
||||
url: str = "https://beschaeftigtenbefragung.verdi.de/",
|
||||
):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user