From 80aa6345e4470c87d88b63fc230e79111e213e96 Mon Sep 17 00:00:00 2001 From: Jake Pullen Date: Thu, 21 Aug 2025 08:34:58 +0100 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=92=84=20I'm=20a=20Teapot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_call | 3 +++ main.py | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 auto_call diff --git a/auto_call b/auto_call new file mode 100644 index 0000000..db593f1 --- /dev/null +++ b/auto_call @@ -0,0 +1,3 @@ +import request + +while true: diff --git a/main.py b/main.py index d0f6fff..f7506aa 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ Serves random compliments from a YAML file via REST API import os import yaml import random -from flask import Flask, jsonify, abort, request +from flask import Flask, jsonify, abort app = Flask(__name__) @@ -37,6 +37,10 @@ def load_compliments(): @app.route(f"/api/{API_VERSION}/compliment", methods=["GET"]) def get_compliment(): """Get a random compliment""" + + if random.random() <= 0.01: + return jsonify({"error": "I'm a Teapot"}), 418 + compliments = load_compliments() if not compliments: