dev_xulongjin b4ef64314b feat(商务大数据分析): 五一前作业更新
- 新增 aqi.csv 文件,包含 2020 年 1 月 1 日至 9 月 27 日的空气质量数据- 数据包括日期、AQI、质量等级以及 PM2.5、PM10、SO2、CO、NO2、O3等污染物含量
2025-05-06 20:31:09 +08:00

22 lines
512 B
Python

import time
from flask import Flask
import redis
app = Flask(__name__)
cache = redis.Redis(host='redis', port=6379)
def get_hit_count():
retries = 5
while True:
try:
return cache.incr('hits')
except redis.exceptions.ConnectionError as exc:
if retries == 0:
raise exc
retries -= 1
time.sleep(0.5)
@app.route('/')
def hello():
count = get_hit_count()
return 'Hello World! I have been seen {} times.\n'.format(count)