benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf fc3aa5b2-0739-5b65-a1eb-a72e021ba17b
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import ipaddress
import requests
def task_func(ip_range, timeout):
"""
Scans a specified IP address range and sends an HTTP GET request to each IP to verify if it is an active web server.
The function requires an IP range in CIDR format (e.g., '192.168.0.0/16') and a timeout value in seconds.
It returns a list of IPs where the request returned a status code of 200. If the request is not success, then ignore and continue
to the next IP address.
Parameters:
ip_range (str): The IP range to scan in CIDR notation.
timeout (int): The timeout for each HTTP GET request in seconds.
Requirements:
- ipaddress
- requests
Returns:
list: A list of IP addresses that responded with a status code of 200.
Raises:
ValueError: If an invalid IP range is provided.
Examples:
>>> type(task_func('192.168.0.0/16', 5)) is list
True
>>> isinstance(task_func('192.168.0.0/16', 5), list)
True
"""
instruct prompt
Scans a specified IP address range and sends an HTTP GET request to each IP to verify if it is an active web server. The function requires an IP range in CIDR format (e.g., '192.168.0.0/16') and a timeout value in seconds. It returns a list of IPs where the request returned a status code of 200. If the request is not success, then ignore and continue to the next IP address.
The function should raise the exception for: ValueError: If an invalid IP range is provided.
The function should output with:
list: A list of IP addresses that responded with a status code of 200.
You should write self-contained code starting with:
Code
import ipaddress
import requests
def task_func(ip_range, timeout):
code prompt
Code
import ipaddress
import requests
def task_func(ip_range, timeout):
entry point
task_func
libs
- requests
- ipaddress
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
initial import