a bit more than 5 lines actually
const app = require('express')(); app.get('/', (req, res) => { console.log("fetching ...", req.query.url); if (req.query.url) fetch(req.query.url, (data) => {res.send(data); }); else res.send("missing url"); }); const port = 9999; app.listen(port, () => { console.log(`fetch a url with http://localhost:${port}?url=https://somÂewhere.com/this-that`); }); function fetch(url, cb) { require("https").get(url, res => { res.setEncoding("utf8"); let body = ""; res.on("data", data => { body += data; }); res.on("end", () => { cb(body); }); }); }
@dumdum started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
a bit more than 5 lines actually