Failed entirely to work on my first attempt with: curl -XHEAD https://google.com It is just flat out wrong on: curl -X HEAD https://google.com In that it does a GET request: import requests response = requests.get('https://google.com/') Clever idea, but my first totally valid example failed (it does OPTIONS, GET, POST, PUT, PATCH successfully)
Convert Curl Syntax to Python Requests
11–20 of 47 posts
Re: Convert Curl Syntax to Python Requests
#12Failed entirely to work on my first attempt with: curl -XHEAD https://google.com It is just flat out wrong on: curl -X HEAD https://google.com In that it does a GET request: import requests response = requests.get('https://google.com/') Clever idea, but my first totally valid example failed (it does OPTIONS, GET, POST, PUT, PATCH successfully)
Re: Convert Curl Syntax to Python Requests
#13Re: Convert Curl Syntax to Python Requests
#14Re: Convert Curl Syntax to Python Requests
#15An helper for building API request, for example, there is this great open source project: https://github.com/Kong/apiembed/
It supports a dozen of language.
Re: Convert Curl Syntax to Python Requests
#16Re: Convert Curl Syntax to Python Requests
#17Re: Convert Curl Syntax to Python Requests
#18I wonder how many cookies/secret headers will be pasted by unaware and unknowing users.
Re: Convert Curl Syntax to Python Requests
#19The design is modular and separates the frontend (curl) from the backend (Python), so more input and output formats can be added. It tries to be smart about generating "clean" code, so it will, for example, remove the Content-Length header when it can be recomputed from the request content.
https://ryan.govost.es/http-translator/
It is also open source. Feedback or pull requests are welcome. https://github.com/rgov/http-translator