From 7e519c4736baedad9bb36c4d22de412555f382a3 Mon Sep 17 00:00:00 2001 From: Annika Backstrom Date: Sun, 9 Apr 2017 21:46:18 -0400 Subject: [PATCH] Create web UI for sending tags Sure, why the hell not. --- bin/tag-reader-dummy | 74 +++++++++++++++++++++++++++++++++++++++++--- nodemon.json | 1 + package.json | 1 + player.js | 1 + 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/bin/tag-reader-dummy b/bin/tag-reader-dummy index 2ab3d27..6acd3c7 100755 --- a/bin/tag-reader-dummy +++ b/bin/tag-reader-dummy @@ -1,5 +1,71 @@ -#!/bin/bash +const express = require('express'); +const bodyParser = require('body-parser'); -while echo 1234567890 ; do - sleep 0.2 -done +const mustache = require('express'); + +var html = ` + + + + + + + +
+
+

tag-reader-dummy

+
+ +
+
+ +
+
+ +
+
+
+ + + +`; + +var app = express(); +var server = require('http').createServer(); + +app.use(bodyParser.urlencoded({ extended: true })); + +app.get('/', function(req, res, next) { + res.send(html); +}); + +app.post('/', function(req, res, next) { + var uid = req.body.uid; + if (uid) { + process.stdout.write(uid); + } + res.send('ok'); +}); + +server.on('request', app); + +server.listen(8191, function () { + process.stderr.write('tag-reader-dummy listening at http://localhost:8191'); +}) diff --git a/nodemon.json b/nodemon.json index 0013b86..5bb2a40 100644 --- a/nodemon.json +++ b/nodemon.json @@ -4,5 +4,6 @@ "player.js" , "jukebox" , "templates" + , "bin/tag-reader-dummy" ] } diff --git a/package.json b/package.json index ff5dd96..0eec539 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "author": "", "license": "ISC", "dependencies": { + "body-parser": "^1.17.1", "express": "^4.14.0", "glob": "^7.1.1", "morgan": "^1.7.0", diff --git a/player.js b/player.js index 0592fa9..b26365a 100644 --- a/player.js +++ b/player.js @@ -54,6 +54,7 @@ process.on('exit', exitHandler.bind(null)); process.on('SIGINT', exitHandler.bind(null, {exit:true})); TagReader.on('message', tag => { + logger.debug("got tag from tagreader", { tag: tag }); MediaLibrary.find(tag); });