HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/buyercall/blueprints/sysadmin/utilities/generate_curl.py
class GenerateCurl:
    @staticmethod
    def curl_generate(request):
        # Get the request method (e.g., GET, POST, etc.)
        method = request.method

        # Get the URL
        url = request.url

        # Get the headers
        headers = ''
        for key, value in request.headers:
            headers += f'-H "{key}: {value}" '

        # Get the request body (if applicable)
        body = request.data

        # Construct the curl command
        curl_command = f'curl -X {method} {headers} -d \'{body.decode("utf-8")}\' {url}'

        return curl_command