RockCoder23 commited on
Commit
e340c17
·
verified ·
1 Parent(s): ce65c89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -15,7 +15,12 @@ def fetch_url_content():
15
  return jsonify({"error": "No URL provided"}), 400
16
 
17
  try:
18
- response = requests.get(target_url)
 
 
 
 
 
19
  return jsonify({
20
  "status_code": response.status_code,
21
  "content": response.text
@@ -23,5 +28,13 @@ def fetch_url_content():
23
  except Exception as e:
24
  return jsonify({"error": str(e)}), 500
25
 
 
 
 
 
 
 
 
 
26
  if __name__ == "__main__":
27
- app.run(host='0.0.0.0', port=7860)
 
15
  return jsonify({"error": "No URL provided"}), 400
16
 
17
  try:
18
+ # Make the GET request to the target URL, with no cache
19
+ response = requests.get(target_url, headers={
20
+ "Cache-Control": "no-cache",
21
+ "Pragma": "no-cache"
22
+ })
23
+
24
  return jsonify({
25
  "status_code": response.status_code,
26
  "content": response.text
 
28
  except Exception as e:
29
  return jsonify({"error": str(e)}), 500
30
 
31
+ # Prevent caching for responses from this Flask app itself
32
+ @app.after_request
33
+ def add_no_cache_headers(response):
34
+ response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0"
35
+ response.headers["Pragma"] = "no-cache"
36
+ response.headers["Expires"] = "-1"
37
+ return response
38
+
39
  if __name__ == "__main__":
40
+ app.run(host='0.0.0.0', port=7860)