benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf c1d37f0b-672d-5e9e-b30e-99717773632b
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import zipfile
import io
from django.http import FileResponse, HttpRequest
from django.conf import settings
def task_func(request, file_paths):
"""
Generates a ZIP file response for a Django HttpRequest, zipping the specified files. This function is useful
for scenarios where multiple file downloads are required in response to a web request. The actual HttpRequest
is not utilized within the function but is required for compatibility with Django view structures.
Parameters:
- request (HttpRequest): The incoming Django HttpRequest, not used within the function.
- file_paths (list of str): A list of file paths or file contents to be included in the zip.
Returns:
- FileResponse: A Django FileResponse object containing the ZIP file as an attachment.
Requirements:
- django.http
- django.conf
- zipfile
- io
Examples:
>>> from django.conf import settings
>>> if not settings.configured:
... settings.configure() # Add minimal necessary settings
>>> from django.http import HttpRequest
>>> request = HttpRequest()
>>> response = task_func(request)
>>> response['Content-Type']
'application/zip'
>>> request = HttpRequest()
>>> response = task_func(request)
>>> response['Content-Disposition']
'attachment; filename="files.zip"'
"""
instruct prompt
Generates a ZIP file response for a Django HttpRequest, zipping the specified files. This function is useful for scenarios where multiple file downloads are required in response to a web request. The actual HttpRequest is not utilized within the function but is required for compatibility with Django view structures.
The function should output with:
FileResponse: A Django FileResponse object containing the ZIP file as an attachment.
You should write self-contained code starting with:
Code
import zipfile
import io
from django.http import FileResponse, HttpRequest
from django.conf import settings
def task_func(request, file_paths):
code prompt
Code
import zipfile
import io
from django.http import FileResponse, HttpRequest
from django.conf import settings
def task_func(request, file_paths):
entry point
task_func
libs
- io
- django
- zipfile
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