From f65e3c603cca31bf9106f71da644003bd256b215 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sat, 9 Sep 2023 16:40:35 +0100 Subject: [PATCH] Make the response cleaner --- main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 92b3fc3..0a881bc 100644 --- a/main.py +++ b/main.py @@ -5,9 +5,10 @@ Take existing calendar and update it slightly from datetime import date, datetime, time, timedelta import requests -from flask import Flask, Response, request +from flask import Flask, Response, request, make_response from icalendar import Calendar, Event from werkzeug.middleware.proxy_fix import ProxyFix +import logging app = Flask(__name__) app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) # type: ignore[assignment] @@ -29,7 +30,8 @@ def process() -> Response: mins = int(request.args.get("mins", "0")) if orig.status_code != 200: - return Response(orig.text, headers=orig.headers, status=orig.status_code) + logging.warning("%s returned a %d", orig.request.url, orig.status_code) + return make_response(orig.text, orig.status_code) orig_cal = Calendar.from_ical(orig.text) cal = Calendar()