Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nondanee/bannero
An image API for simpledesktops.com
https://github.com/nondanee/bannero
cloudflare-worker
Last synced: 6 days ago
JSON representation
An image API for simpledesktops.com
- Host: GitHub
- URL: https://github.com/nondanee/bannero
- Owner: nondanee
- License: mit
- Created: 2019-06-08T11:21:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-20T06:04:14.000Z (over 5 years ago)
- Last Synced: 2024-08-01T16:34:51.923Z (3 months ago)
- Topics: cloudflare-worker
- Homepage: https://bannero.nondanee.tk
- Size: 5.86 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cloudflare - Bannero - Bannero image API for simpledesktops. (Workers / Recipes)
- awesome-cloudflare - Bannero - Bannero image API for simpledesktops. (Workers / Recipes)
README
Bannero API
🚀🥇🗳
Simple random banner pictures for blogs, websites and more.
## About
Another way to implement [spencerwooo/bannero](https://github.com/spencerwooo/bannero) API service
Just for seeking a new free approach to host an redirect server
Powered by [Cloudflare Worker®](https://workers.cloudflare.com/docs)
*Workers Free plan Includes 100,000 total requests per day*
## Deployment
I think this simple code do not need the help of [wrangler CLI tool](https://github.com/cloudflare/wrangler) and webpack
Only 3 steps:
1. Goto the Cloudflare Worker® DashBoard
2. Create a new script with the following code
3. Add a route and deploy it```javascript
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})const handleRequest = async request => {
let list = await bannero(request)
let choice = crypto.getRandomValues(new Uint16Array(1))[0] % list.length
return Response.redirect(list[choice], 302)
}const bannero = async () => {
let remote = await fetch('https://raw.githubusercontent.com/spencerwooo/bannero/master/src/bannero.txt', {cf: {cacheEverything: true}})
let text = await remote.text()
return text.split('\n').slice(0, -1)
}
```> The code will be deployed to hundreds of data centers around the world returning responses to your users faster than your origin ever could. You get all the speed and security of the world’s most peered CDN with all the power of JavaScript.
## Reference
- [spencerwooo/bannero](https://github.com/spencerwooo/bannero)
## License
MIT