Make the response cleaner

This commit is contained in:
Scott Wallace 2023-09-09 16:40:35 +01:00
parent 49a50a0edd
commit f65e3c603c
Signed by: scott
GPG key ID: AA742FDC5AFE2A72

View file

@ -5,9 +5,10 @@ Take existing calendar and update it slightly
from datetime import date, datetime, time, timedelta from datetime import date, datetime, time, timedelta
import requests import requests
from flask import Flask, Response, request from flask import Flask, Response, request, make_response
from icalendar import Calendar, Event from icalendar import Calendar, Event
from werkzeug.middleware.proxy_fix import ProxyFix from werkzeug.middleware.proxy_fix import ProxyFix
import logging
app = Flask(__name__) app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) # type: ignore[assignment] 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")) mins = int(request.args.get("mins", "0"))
if orig.status_code != 200: 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) orig_cal = Calendar.from_ical(orig.text)
cal = Calendar() cal = Calendar()