Last active
August 14, 2018 01:58
-
-
Save johnelliott/6c2dcaf9c7019e2cd5d0b87b7e9bb2ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const url = require('url') | |
const querystring = require('querystring') | |
const http = require('http') | |
const rcLocation = process.env.STREAMRC_PATH | |
if (!rcLocation) { | |
console.error('no STREAMRC_PATH, exiting') | |
process.exit(1) | |
} | |
console.log(fs.readFileSync(rcLocation, 'utf8')) | |
const server = http.createServer((req, res) => { | |
// TODO check path or querystring | |
console.log('ytkey', querystring.parse(url.parse(req.url).query).ytkey) | |
const youtubeKey = querystring.parse(url.parse(req.url).query).ytkey | |
fs.writeFileSync(rcLocation, youtubeKey) | |
// TODO bounce the ffmpeg service to pick up the new envfile | |
res.setHeader('Content-Type', 'text/plain') | |
res.statusCode = 200 | |
res.write(res.statusCode.toString()) | |
res.end() | |
}) | |
const hostname = 'localhost' | |
const port = process.env.PORT || 3000 | |
server.listen(port, hostname, () => { | |
console.log(`Server running at http://${hostname}:${port}/`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment