Added /timeout route

This commit is contained in:
Felipe M 2020-09-25 10:11:55 +02:00
parent 8936f7867f
commit 7efb4d5cde
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 14 additions and 0 deletions

14
app.py
View File

@ -3,6 +3,7 @@ import logging
import os
import sys
import subprocess
import time
import requests
from flask import Flask, request, Response, render_template, jsonify
@ -161,6 +162,19 @@ def request_view():
)
@app.route("/timeout", methods=["GET"])
def timeout_view():
"""
Forces a slow response from the request
Usage:
/timeout?duration=301 (in seconds)
"""
duration = int(request.args.get("duration", 300))
time.sleep(duration)
return jsonify({"duration": duration})
@app.route("/curl", methods=["POST"])
def curl_view():
"""