Skip to content

Instantly share code, notes, and snippets.

@theabbie
Created October 20, 2020 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theabbie/a33304b4b815d1ce5e6593cd3f5b339d to your computer and use it in GitHub Desktop.
Save theabbie/a33304b4b815d1ce5e6593cd3f5b339d to your computer and use it in GitHub Desktop.
Random DevRant
var app = require('express')();
var axios = require('axios');
app.get("/*", async function(req,res) {
try {
var rants = (await axios("https://del.dog/raw/rants")).data.split("\n");
var rant = rants[Math.floor(Math.random()*rants.length)];
res.redirect(307,"https://devrant.com/rants/"+rant);
}
catch (e) {
res.end(e.message);
}
})
app.listen(process.env.PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment