Skip to main content

A Python package to parse and execute cURL commands

Project description

curlr

curlr is a Python package that allows you to parse and execute cURL commands easily.

Installation

You can install curlr using pip:

pip install curlr

Usage

Here's a simple example of how to use curlr:

import requests
from curlr import CURL

# Using a cURL command string
curl_command = "curl -X POST -H 'Content-Type: application/json' -d '{\"key\":\"value\"}' https://api.example.com/endpoint"
curl = CURL(command=curl_command)

# Or using a file containing the cURL command
# curl = CURL(path="path/to/curl.txt")

# Get a prepared request
request = curl.request()

# Execute the request
response = curl.execute()# equivalent to: requests.Session().send(request)

# Or use individual properties
response = getattr(requests, curl.method.lower())(
    curl.url,
    headers=curl.headers,
    cookies=curl.cookies,
    json=curl.data
)

print(response.status_code)
print(response.json())

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

curlr-0.1.2.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

curlr-0.1.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page