benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2c82537a-8040-552b-8a7d-841e68b64007

Problem

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

complete prompt

from datetime import datetime
import json

SERVER_ADDRESS = "localhost"
BUFFER_SIZE = 1024


def task_func(client_socket):
    """
    Responds to a client's request by sending a JSON-formatted message containing
    the current server time and a greeting.

    Parameters:
    - client_socket (socket.socket): The client socket from which the request is received.

    Requirements:
    - datetime.datetime
    - json

    Returns:
    - None

    Example:
    >>> import socket
    >>> server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    >>> server_socket.bind((SERVER_ADDRESS, 0))  # Bind to a free port
    >>> server_socket.bind((SERVER_ADDRESS, 8080))
    >>> server_socket.listen(1)
    >>> try:
    ...     client_socket, _ = server_socket.accept()
    ...     task_func(client_socket)
    ... finally:
    ...     server_socket.close()
    """

instruct prompt

Responds to a client's request by sending a JSON-formatted message containing the current server time and a greeting.
The function should output with:
    None
You should write self-contained code starting with:

Code

from datetime import datetime
import json
SERVER_ADDRESS = "localhost"
BUFFER_SIZE = 1024
def task_func(client_socket):

code prompt

Code

from datetime import datetime
import json
SERVER_ADDRESS = "localhost"
BUFFER_SIZE = 1024
def task_func(client_socket):

entry point

task_func

libs

  • datetime
  • 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