added expressjs server instead of python one

This commit is contained in:
janis
2022-10-30 15:02:25 +01:00
parent ab47525e7b
commit f5b682598b
623 changed files with 88586 additions and 64 deletions

68
nodeserver/server.js Normal file
View File

@@ -0,0 +1,68 @@
const express = require('express');
const http = require('http');
const bodyParser = require('body-parser');
const ip = require('ip')
// GET IP OF SYSTEM AND DISPLAY TO USER
console.log("\n\nThis PC's IP address: " + ip.address());
console.log("Use this IP address when connecting to this server from the player and display!")
// INITIALIZE VARIABLES
var app = express();
app.use(bodyParser.urlencoded({extended : true}))
/////////////////
////// API //////
/////////////////
app.get('/tryconnect', (request, response) => {
console.log("connecting")
response.send("ok")
})
// Get data (Interface for Screen)
app.get('/playbackpos', (request, response) => {
response.send(1)
})
app.get('/upcomingsongs', (request, response) => {
response.send("This is a song")
})
app.get('/songmaxlength', (request, response) => {
response.send(100)
})
app.get('/currentsong', (request, response) => {
response.send("Test\nTest2\nTest3")
})
// POST data (Interface for Player)
app.post('/posplayback', (request, response) => {
})
app.post('/postupcomingsogns', (request, response) => {
})
// Test functions
app.post('/testrequest', (request, response) => {
console.log("request received")
console.log(request.body)
response.send(request.body)
response.status(200)
})
// Create and run server
http.createServer(app).listen(8000, function () {
console.log("\n\n-------------------\n\n Server started\n\n-------------------\n")
})