TIL How to test a Flask server locally with CURL
This might be a bit of a basic one, but I was testing a codebase that
implemented an ML model behind an endpoint with Flask at /api/redact, which
accepted a json input and returned a json output.
I hosted the Flask app locally on port 5001 and used this command to invoke a response
curl -X POST http://localhost:5001/api/redact -H "Content-Type: application/json" -d '{"text": "John Doe lives at 123 Baker Street. You can contact him at john.doe@example.com or 555-123-4567."}'
# {
# "redacted_text": "[NAME] lives at [ADDRESS]. You can contact him at [EMAIL] or [ADDRESS]."
# }#data-redaction #flask #machine-learning #json #api-testing #testing #curl #deep-learning #python #local-development #privacy #api-development
Reply to this post by email blZake@proZbableodyssey.blog (remove Z characters) ↪
Comments
Leave a comment
Markdown is supported. Your email is private and only used if you'd like a reply.