testing changing cache
This commit is contained in:
@@ -6,6 +6,6 @@ def init_healthcheck(app):
|
|||||||
def healthcheck():
|
def healthcheck():
|
||||||
"""Health check route to monitor service status"""
|
"""Health check route to monitor service status"""
|
||||||
try:
|
try:
|
||||||
return Response("Works normally", status=200)
|
return Response("healthy", status=200)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Error: {e}", 500
|
return f"Error: {e}", 500
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ import os
|
|||||||
import requests
|
import requests
|
||||||
import redis
|
import redis
|
||||||
import xml.etree.ElementTree as ET
|
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")
|
PROXY_URL = os.getenv("PROXY_URL")
|
||||||
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
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)
|
rdb = redis.from_url(REDIS_URL)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/proxy")
|
def init_proxy(app):
|
||||||
def proxy():
|
@app.route("/proxy")
|
||||||
|
def proxy():
|
||||||
"""Proxy RSS feed with per-item caching."""
|
"""Proxy RSS feed with per-item caching."""
|
||||||
raw_query = request.query_string.decode()
|
raw_query = request.query_string.decode()
|
||||||
if raw_query.startswith("url="):
|
if raw_query.startswith("url="):
|
||||||
@@ -58,7 +58,3 @@ def proxy():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Error: {e}", 500
|
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."""
|
"""Check health endpoint."""
|
||||||
response = self.app.get('/health')
|
response = self.app.get('/health')
|
||||||
self.assertEqual(response.status_code, 200)
|
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")
|
@patch("proxy.rss_proxy.requests.get")
|
||||||
def test_proxy_success(self, mock_get):
|
def test_proxy_success(self, mock_get):
|
||||||
|
|||||||
Reference in New Issue
Block a user