Spaces:
Sleeping
Sleeping
|
Download examples/hf-generated/calculator/design.md from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/examples/hf-generated/calculator/design.md
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/examples/hf-generated/calculator/design.md
-
curl -L -o design.md https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/examples/hf-generated/calculator/design.md
1.04 kB
| Implement demo.App using Java 17 com.sun.net.httpserver.HttpServer on port 8080. Single-threaded bounded executor. Root handler routes: /health (GET->200 {"status":"ok"}), /api/calculate (GET only, else 405). Calculate requires Authorization header 'Bearer demo-calculator' (else 401). Query param expression64 must be exactly one non-empty key; value is unpadded base64url of UTF-8 expression. Validate encoded length <=256 and decoded length <=128. Use CharsetDecoder REPORT for strict UTF-8. Recursive descent parser: sum=product((+|-)product)*, product=unary((*|/)unary)*, unary=(+|-)*atom, atom=number|(sum). Numbers: digits(.digits+)? or .digits+. Allow spaces between tokens. Enforce limits: depth<=16, ops<=64, literal digits<=24, abs(value)<=1e24. Evaluate with BigDecimal DECIMAL128. Division by zero -> 400 DIVISION_BY_ZERO. Parse/Limit errors -> 400 INVALID_EXPRESSION or 422 LIMIT_EXCEEDED. Final result: round HALF_UP scale 12, strip trailing zeros, toPlainString. Return JSON {"expression":"...","result":"..."}. Close exchanges. |