HTTP

Simuler une réponse 418 I'm a Teapot

Any attempt to brew coffee with a teapot should result in this error. An April Fools' joke from 1998 that became a beloved part of HTTP culture.

Voir la référence complète →

1 Réponse HTTP

Réponse HTTP
HTTP/1.1 418 I'm a Teapot
Content-Type: application/json
Date: Tue, 25 Feb 2026 12:00:00 GMT
Content-Length: 52

{
  "error": "i'm_a_teapot",
  "message": "I'm a Teapot"
}

2 Tester avec curl

terminal
curl -i https://httpbin.org/status/418

3 Retourner 418 I'm a Teapot dans votre framework

django
from django.http import JsonResponse


def my_view(request):
    return JsonResponse(
        {"error": "i'm_a_teapot", "message": "I'm a Teapot"},
        status=418,
    )
flask
from flask import Flask, jsonify

app = Flask(__name__)


@app.route("/endpoint")
def my_endpoint():
    return jsonify({"error": "i'm_a_teapot", "message": "I'm a Teapot"}), 418
fastapi
from fastapi import FastAPI
from fastapi.responses import JSONResponse

app = FastAPI()


@app.get("/endpoint")
def my_endpoint():
    return JSONResponse(
        content={"error": "i'm_a_teapot", "message": "I'm a Teapot"},
        status_code=418,
    )
express.js
// Express.js
app.get('/endpoint', (req, res) => {
  res.status(418).json({"error": "i'm_a_teapot", "message": "I'm a Teapot"});
});
spring boot
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
public class MyController {

    @GetMapping("/endpoint")
    public ResponseEntity<Map<String, Object>> myEndpoint() {
        return ResponseEntity
            .status(418)
            .body(Map.of("error", "i'm_a_teapot",
                         "message", "I'm a Teapot"));
    }
}
go net/http
package main

import (
    "encoding/json"
    "net/http"
)

func myHandler(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "application/json")
    w.WriteHeader(418)
    json.NewEncoder(w).Encode(map[string]string{
        "error":   "i'm_a_teapot",
        "message": "I'm a Teapot",
    })
}
ruby on rails
class MyController < ApplicationController
  def my_action
    render json: {"error": "i'm_a_teapot", "message": "I'm a Teapot"},
           status: :i'm_a_teapot
  end
end
asp.net core
// ASP.NET Core Minimal API
app.MapGet("/endpoint", () =>
    Results.Json(
        new { error = "i'm_a_teapot", message = "I'm a Teapot" },
        statusCode: 418
    )
);

Plus de pages Mock HTTP