cas*_*ase 1 python flask d3.js
我有一个使用/get_data端点访问的烧瓶应用程序并提供一个数字作为 id ( 127.0.0.1:55555/get_data=56)
@app.route('/get_data=<id>')
def get_vod_tree(id):
...
return render_template('index.html')
Run Code Online (Sandbox Code Playgroud)
它调用一个函数来获取该 id 下的一些数据,并使用收集的数据创建一个 json 文件 [static/data.json],然后返回 render_template('index.html')。
在 index.html 中有对 ../static/data_tree.js 的调用,它依次读取 json 文件并使用 d3.js 在浏览器中输出可视化。
当应用程序运行时,即使我使用不同的 id 并且 json 文件更改,我也会在浏览器上获得相同的输出。它仅在我重新加载应用程序然后访问 url 时才有效。
我的问题是: 如何确保多个用户根据 id 获得不同的输出,或者如何在到达端点时重新加载应用程序。
事后思考:如果多个用户正在使用该应用程序,那么每次只会创建一个文件
感谢您的回答。它有助于深入了解这一点。它现在是这样工作的:
@app.after_request
def apply_caching(response):
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
return response
Run Code Online (Sandbox Code Playgroud)
因此,通过禁用缓存,应用程序可以将每个请求视为唯一的。
| 归档时间: |
|
| 查看次数: |
3522 次 |
| 最近记录: |