/ justapi / benchmarks / workloads_bt5.py
swadhinbiswas WIP save-point: production hardening, H3 removal, fmt gate, and accumulated phase work · 7/15/2026
2080d40
24 lines · 572 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from justapi import JustAPIApp, Schema
import json

app = JustAPIApp()

@app.post("/body_json")
def body_json(request):
    return json.loads(request["body"].decode("utf-8"))

# Variant B: native=False, WITH schema (non-native route w/ schema)
class ItemSchema(Schema):
    id: int
    name: str
    price: float

@app.post("/with_schema", schema=ItemSchema)
def with_schema(request):
    return json.loads(request["body"].decode("utf-8"))

if __name__ == "__main__":
    import sys
    port = sys.argv[1] if len(sys.argv) > 1 else "8246"
    app.run(f"127.0.0.1:{port}")