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
1curl -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."}'
2# {
3# "redacted_text": "[NAME] lives at [ADDRESS]. You can contact him at [EMAIL] or [ADDRESS]."
4# }