Wood Chen

Random-Api Random File API

0 comments381 views267 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

Added a method using edgeone edge functions for faster access from China: https://woodchen.ink/archives/use-tencent-edgeone-edge-function-to-achieve-random-chart-api-1vfbot

Repository: https://github.com/woodchen-ink/Random-Api

Random-Api Random File API

Uses cloudflare worker with github Pages to map path to csv_path and serve a random file from the links listed in url.csv

It supports not only images, but also text files, videos, and more

API

I'll keep it updated at: https://random-api.woodchen.ink/

Deployment

Add your own resources and customize the content

  1. fork my github project
  2. In app.js, update the url.json reference on line 18 and the homepage content, including your own website URL
  3. Then update your url.json and the contents of the url folder
  1. Copy the entire github project into a directory
  2. Run the project in the nodejs directory, as shown belowimage (16).webp
  3. Create a website in nginx and configure a reverse proxy to the project's port

  1. Create a worker in cloudflare, paste in the code from worker.js, and save it (you can replace the links with your own)
  2. Visit it to use the API

A few notes

  1. I'll keep my site publicly available. Feel free to use it for small sites, but please deploy your own instance for high-traffic sites. Most of the image CDN traffic uses optimized cloudfront endpoints, and exceeding the traffic allowance gets expensive.
  2. If any resources stop working, or you'd like to recommend your own resources, please leave a comment.

Last updated 2024-07-28

Related posts

Comments 0