style: 💄 I'm a Teapot

This commit is contained in:
2025-08-21 08:34:58 +01:00
parent 0bfee11e0e
commit 80aa6345e4
2 changed files with 8 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
import request
while true:
+5 -1
View File
@@ -7,7 +7,7 @@ Serves random compliments from a YAML file via REST API
import os import os
import yaml import yaml
import random import random
from flask import Flask, jsonify, abort, request from flask import Flask, jsonify, abort
app = Flask(__name__) app = Flask(__name__)
@@ -37,6 +37,10 @@ def load_compliments():
@app.route(f"/api/{API_VERSION}/compliment", methods=["GET"]) @app.route(f"/api/{API_VERSION}/compliment", methods=["GET"])
def get_compliment(): def get_compliment():
"""Get a random compliment""" """Get a random compliment"""
if random.random() <= 0.01:
return jsonify({"error": "I'm a Teapot"}), 418
compliments = load_compliments() compliments = load_compliments()
if not compliments: if not compliments: