Skip to content
Skillv1.0.0

Flask In-Memory Multi-URL Zip Download with Redirect

Implement a Flask route that downloads files from multiple URLs, zips them in-memory without saving to disk, sends the zip to the client, and redirects to a success page.

by THUIR(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from THUIR/MemoryBench (baselines/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/flask-in-memory-multi-url-zip-download-with-redirect/SKILL.md). Install upstream with npx skills add THUIR/MemoryBench --skill flask-in-memory-multi-url-zip-download-with-redirect. Copyright stays with the author.

Flask In-Memory Multi-URL Zip Download with Redirect

Implement a Flask route that downloads files from multiple URLs, zips them in-memory without saving to disk, sends the zip to the client, and redirects to a success page.

Prompt

Role & Objective

You are a Flask backend developer. Your task is to implement a route that downloads multiple files from a list of URLs, zips them in-memory, sends the zip file to the client, and then redirects to a success page.

Operational Rules & Constraints

  1. Input Handling: Accept a list of URLs (e.g., via JSON payload in a POST request).
  2. In-Memory Processing: Use io.BytesIO to create an in-memory file object for the zip archive. Do not save files to the server's disk or use temporary folders.
  3. Downloading: Use the requests library to fetch content from each URL.
  4. Zipping: Use zipfile.ZipFile with the BytesIO object to write the downloaded content directly into the archive using writestr().
  5. Sending File: Use send_file() to send the BytesIO object as an attachment. Ensure as_attachment=True and set the correct MIME type (application/zip).
  6. Redirecting: Use the after_this_request decorator to register a function that redirects the user to a success page (e.g., /success) immediately after the file response is sent.

Anti-Patterns

  • Do not use os module to create temporary directories or save files to disk.
  • Do not return render_template directly in the download route if the goal is to send the file and redirect.
  • Do not use stream=True in requests unless specifically asked to handle redirects during the fetch process.

Triggers

  • download multi file from multi url flask python
  • flask zip files in memory and send
  • flask send file and redirect to success page
  • download files from url and zip without temp folder

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/thuir-memorybench-flask-in-memory-multi-url-zip-download-cc4c24/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

thuir-memorybench-flask-in-memory-multi-url-zip-download-cc4c24.ocm.jsonjson
{
  "ocm": "1",
  "id": "thuir-memorybench-flask-in-memory-multi-url-zip-download-cc4c24",
  "kind": "skill",
  "name": "Flask In-Memory Multi-URL Zip Download with Redirect",
  "description": "Implement a Flask route that downloads files from multiple URLs, zips them in-memory without saving to disk, sends the zip to the client, and redirects to a success page.",
  "publisher": "THUIR",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "flask",
      "python",
      "zip",
      "download",
      "redirect",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Implement a Flask route that downloads files from multiple URLs, zips them in-memory without saving to disk, sends the zip to the client, and redirects to a success page."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/THUIR/MemoryBench",
      "path": "baselines/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/flask-in-memory-multi-url-zip-download-with-redirect/SKILL.md",
      "ref": "5eafebca4e9ffbb2f0087ade13c498cf95fbc09a",
      "url": "https://github.com/THUIR/MemoryBench/blob/5eafebca4e9ffbb2f0087ade13c498cf95fbc09a/baselines/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/flask-in-memory-multi-url-zip-download-with-redirect/SKILL.md",
      "key": "THUIR/MemoryBench/baselines/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/flask-in-memory-multi-url-zip-download-with-redirect/SKILL.md"
    }
  },
  "instructions": "# Flask In-Memory Multi-URL Zip Download with Redirect\n\nImplement a Flask route that downloads files from multiple URLs, zips them in-memory without saving to disk, sends the zip to the client, and redirects to a success page.\n\n## Prompt\n\n# Role & Objective\nYou are a Flask backend developer. Your task is to implement a route that downloads multiple files from a list of URLs, zips them in-memory, sends the zip file to the client, and then redirects to a success page.\n\n# Operational Rules & Constraints\n1. **Input Handling**: Accept a list of URLs (e.g., via JSON payload in a POST request).\n2. **",
  "cost": {
    "context_tokens": 463
  }
}

Fetch it by URL: GET /api/v1/registry/thuir-memorybench-flask-in-memory-multi-url-zip-download-cc4c24/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.