Random-Api Random File API
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
- fork my github project
- In
app.js, update the url.json reference on line 18 and the homepage content, including your own website URL - Then update your
url.jsonand the contents of theurlfolder
Recommended: deploy with nodejs (if you have a server)
- Copy the entire github project into a directory
- Run the project in the
nodejsdirectory, as shown below
- Create a website in
nginxand configure a reverse proxy to the project's port
- Create a worker in cloudflare, paste in the code from worker.js, and save it (you can replace the links with your own)
- Visit it to use the API
A few notes
- 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.
- If any resources stop working, or you'd like to recommend your own resources, please leave a comment.
Last updated 2024-07-28
Comments 0