testing changing cache
This commit is contained in:
@@ -6,6 +6,6 @@ def init_healthcheck(app):
|
||||
def healthcheck():
|
||||
"""Health check route to monitor service status"""
|
||||
try:
|
||||
return Response("Works normally", status=200)
|
||||
return Response("healthy", status=200)
|
||||
except Exception as e:
|
||||
return f"Error: {e}", 500
|
||||
|
||||
@@ -3,19 +3,19 @@ import os
|
||||
import requests
|
||||
import redis
|
||||
import xml.etree.ElementTree as ET
|
||||
from flask import Flask, request, Response
|
||||
from flask import request, Response
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
PROXY_URL = os.getenv("PROXY_URL")
|
||||
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
||||
CACHE_TTL = int(os.getenv("CACHE_TTL", 3600)) # По умолчанию 1 час
|
||||
CACHE_TTL = int(os.getenv("CACHE_TTL", 3600))
|
||||
|
||||
rdb = redis.from_url(REDIS_URL)
|
||||
|
||||
|
||||
@app.route("/proxy")
|
||||
def proxy():
|
||||
def init_proxy(app):
|
||||
@app.route("/proxy")
|
||||
def proxy():
|
||||
"""Proxy RSS feed with per-item caching."""
|
||||
raw_query = request.query_string.decode()
|
||||
if raw_query.startswith("url="):
|
||||
@@ -58,7 +58,3 @@ def proxy():
|
||||
|
||||
except Exception as e:
|
||||
return f"Error: {e}", 500
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5050)
|
||||
|
||||
@@ -15,7 +15,7 @@ class FlaskTestCase(unittest.TestCase):
|
||||
"""Check health endpoint."""
|
||||
response = self.app.get('/health')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data, b'Works normally')
|
||||
self.assertEqual(response.data, b'healthy')
|
||||
|
||||
@patch("proxy.rss_proxy.requests.get")
|
||||
def test_proxy_success(self, mock_get):
|
||||
|
||||
Reference in New Issue
Block a user