benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 253e936a-3a83-59c3-b0b8-1316f412e32f

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import requests
import json
import base64

def task_func(data, url="http://your-api-url.com"):
    """
    Convert a Python dictionary into a JSON-formatted string, encode this string in base64 format,
    and send it as a 'payload' in a POST request to an API endpoint.
    
    Parameters:
    data (dict): The Python dictionary to encode and send.
    url (str, optional): The API endpoint URL. Defaults to "http://your-api-url.com".
    
    Returns:
    requests.Response: The response object received from the API endpoint after the POST request.
    
    Requirements:
    - requests
    - json
    - base64
    
    Example:
    >>> data = {'name': 'John', 'age': 30, 'city': 'New York'}
    >>> response = task_func(data, url="http://example-api-url.com")
    >>> print(response.status_code)
    200
    """

instruct prompt

Convert a Python dictionary into a JSON-formatted string, encode this string in base64 format, and send it as a 'payload' in a POST request to an API endpoint.
The function should output with:
    requests.Response: The response object received from the API endpoint after the POST request.
You should write self-contained code starting with:

Code

import requests
import json
import base64
def task_func(data, url="http://your-api-url.com"):

code prompt

Code

import requests
import json
import base64
def task_func(data, url="http://your-api-url.com"):

entry point

task_func

libs

  • base64
  • requests
  • json

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import