Skip to content

Instantly share code, notes, and snippets.

@ericmigi
Created October 20, 2019 23:13
Show Gist options
  • Select an option

  • Save ericmigi/a3ee58767e234cda6332902960759eb2 to your computer and use it in GitHub Desktop.

Select an option

Save ericmigi/a3ee58767e234cda6332902960759eb2 to your computer and use it in GitHub Desktop.
for eink.page
const request = require('request')
const express = require('express')
const app = express()
const port = 3000
var south;
var north;
request({
url: "https://wrapapi.com/use/ericmigi/caltrain/paloalto/0.0.1",
json: true,
method: "POST",
body: {
"wrapAPIKey": "7TI1gW8AVNYbyLzMiicfF69gHwUrUoG6"
}
}, function(err,res,body) {
console.log('next southbound train: ' + body.data.south[0].type + ' in ' + body.data.south[0].time);
console.log('next northbound train: ' + body.data.north[0].type + ' in ' + body.data.north[0].time);
south = body.data.south[0];
north = body.data.north[0];
});
//app.get('/', (req, res) => res.send('Next southbound: '+ south.type + ' in ' + south.time + '<br>Next northbound: ' + north.type + ' in ' + north.time))
app.get('/caltrain.css', (req, res) => res.send('.clock{padding:0;text-align:left}.time{font-weight:700;font-size:600%;line-height:100%;font-family:"Space Mono", monospace;}.clock.widget .time{font-size:400%;margin-bottom:1em;font-family:"Space Mono", monospace;}'))
app.get('/base.css', (req, res) => res.send('body.dark,body.dark .bg-themeable,body.light .fg-themeable,html.inverted body.dark .fg-themeable,html.inverted body.light,html.inverted body.light .bg-themeable{background-color:#000;color:#fff}body.dark .fg-themeable,body.light,body.light .bg-themeable,html.inverted body.dark,html.inverted body.dark .bg-themeable,html.inverted body.light .fg-themeable{background-color:#fff;color:#000}body{font-family:Helvetica Neue,Helvetica Neue LT,sans-serif;margin:0;overflow-x:hidden;overflow-y:scroll}body.standalone{margin:2em}.h1,h1{font-size:500%;line-height:100%}.h1,.h2,h1,h2{font-weight:700}.h2,h2{font-size:200%;margin-bottom:1em}.h3,h3{letter-spacing:.33em;opacity:.5;text-transform:uppercase;font-weight:400}#kindle-console{max-height:50%;line-height:1em;overflow:scroll;position:fixed;bottom:0;left:0;right:0;background:#fff;border-top:1px solid #ccc;color:#000;width:100%;opacity:.85;text-align:left;font-family:monospace;font-size:.5em;word-wrap:break-word;padding:0 0 .3em}#kindle-console>div{padding:.5em}.widget{margin-bottom:2em}.menu{float:right}.menu .menu-button{text-align:right;padding:1em;opacity:.5;width:1em;height:1em;background-size:1em;background-repeat:no-repeat;background-position:50%;background-image:url(/outline-more_horiz-24px.e768254a.svg)}.menu:not(.expanded) .menu-content{display:none}.menu-item{padding:.5em 1em}.menu-item:active{background:#000;color:#fff}.menu .menu-content{background:#fff;position:absolute;z-index:100;right:1em;border:1px solid #000}button{padding:.5em 1em;background:#000;color:#fff;border:none;border-radius:10em;font-size:.7em}#settings-container{border-top:1px dotted grey}'))
var header = '<html class="screensaver gr__eink_page"><head><meta http-equiv="refresh" content="120"><meta name="viewport" content="width=device-width, user-scalable=no"><title>Caltrain</title><link href="https://fonts.googleapis.com/css?family=Space+Mono&display=swap" rel="stylesheet"><meta charset="utf-8"><link href="/base.css" rel="stylesheet"><style>body{margin:2em;overflow:hidden};</style><link rel="stylesheet" href="/caltrain.css"><style type="text/css">body, select {font-size:36px}.kindle-fullheight {height:887px</style></head>';
app.get('/', (req, res) => res.send(header +'<body data-gr-c-s-loaded="true"><div id="root"><div id="clock-container" class="clock"><div class="date h3">NORTH</div><div class="date h3" style="text-align:right;">'+ north.type + '</div><div class="time">' + north.time.replace(' min.', 'm') + '</div></div></div><br> <div id="root"><div id="clock-container" class="clock"><div class="date h3">SOUTH</div><div class="date h3" style="text-align:right">'+ south.type +'</div><div class="time">' + south.time.replace(' min.', 'm') + '</div></div></div> </body></html>'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment