Skip to content

Instantly share code, notes, and snippets.

@xobust
Created March 20, 2024 15:15
Show Gist options
  • Save xobust/3b47fe934690bdbae6c9d64560f9cc85 to your computer and use it in GitHub Desktop.
Save xobust/3b47fe934690bdbae6c9d64560f9cc85 to your computer and use it in GitHub Desktop.
Test server that verifies that the CSTV broadcast resends in case of server errors
from flask import Flask, request
import time
app = Flask(__name__)
# This dictionary will store the paths that have been requested.
requested_paths = {}
@app.route('/', defaults={'path': ''}, methods=['GET', 'POST'])
@app.route('/<path:path>', methods=['GET', 'POST'])
def handle_path(path):
# We always return 200 for start requests
if "/start" in path:
return "This path ends with '/start' and always returns 200.", 200
# Check if the path has been requested before
if path in requested_paths:
# If the path has been requested before, return 200 OK
return "Ok", 200
else:
# If it's the first time the path is requested, mark it as requested and return 500
requested_paths[path] = True
return "Internal error retry", 500
if __name__ == '__main__':
app.run(debug=True, port=5002)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment