Compare commits
12 Commits
79363af3ec
...
main
Author | SHA1 | Date | |
---|---|---|---|
e01c5ff912
|
|||
c362d041fa
|
|||
890207d1cf
|
|||
e00d71109f
|
|||
35f8b30348 | |||
2967816407
|
|||
90dafc2b83
|
|||
bd590172b4
|
|||
afaa27a0ea
|
|||
3975490017
|
|||
adc1a26856
|
|||
5d6f14fbba
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/Server/scripts/
|
61
Server/Source/Config.ts
Normal file
61
Server/Source/Config.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
export interface Config {
|
||||||
|
abfall: Abfall;
|
||||||
|
abfall_after: Abfall;
|
||||||
|
heizmodus: Heizprogramm;
|
||||||
|
fensterzf: Fensterstatus;
|
||||||
|
aussenklima: Aussenklima;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Abfall {
|
||||||
|
uri: string;
|
||||||
|
text: string;
|
||||||
|
date: string;
|
||||||
|
in_days: string;
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Heizprogramm {
|
||||||
|
uri: string;
|
||||||
|
state: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Fensterstatus {
|
||||||
|
uri: string;
|
||||||
|
state: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Aussenklima {
|
||||||
|
uri: string;
|
||||||
|
temp: string;
|
||||||
|
feuchte: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const cfg: Config = {
|
||||||
|
"abfall": {
|
||||||
|
"uri": "/abfall",
|
||||||
|
"text": "Nächste Abholung",
|
||||||
|
"date": "trashschedule.0.next.dateFormat",
|
||||||
|
"in_days": "trashschedule.0.next.daysLeft",
|
||||||
|
"type": "trashschedule.0.next.typesText"
|
||||||
|
},
|
||||||
|
"abfall_after": {
|
||||||
|
"uri": "/danachabfall",
|
||||||
|
"text": "Kommende Abholung",
|
||||||
|
"date": "trashschedule.0.nextAfter.dateFormat",
|
||||||
|
"in_days": "trashschedule.0.nextAfter.daysLeft",
|
||||||
|
"type": "trashschedule.0.nextAfter.typesText"
|
||||||
|
},
|
||||||
|
"heizmodus": {
|
||||||
|
"uri": "/heizmodus",
|
||||||
|
"state": "hm-rega.0.3897"
|
||||||
|
},
|
||||||
|
"fensterzf": {
|
||||||
|
"uri": "/fensterzf",
|
||||||
|
"state": "0_userdata.0.OPEN_WINDOWS.COUNT"
|
||||||
|
},
|
||||||
|
"aussenklima": {
|
||||||
|
"uri": "/aussenklima",
|
||||||
|
"temp": "hm-rpc.0.000EDD89B3A1C4.1.ACTUAL_TEMPERATURE",
|
||||||
|
"feuchte": "hm-rpc.0.000EDD89B3A1C4.1.HUMIDITY"
|
||||||
|
}
|
||||||
|
}
|
51
Server/Source/DataHandler.ts
Normal file
51
Server/Source/DataHandler.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { cfg } from "./Config";
|
||||||
|
import { Database } from "./LocalDatabase";
|
||||||
|
|
||||||
|
export class DataHandler {
|
||||||
|
private db: &Database;
|
||||||
|
|
||||||
|
constructor(db: &Database) {
|
||||||
|
this.db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid_uri(uri: string) {
|
||||||
|
let found: boolean = false;
|
||||||
|
for(const key of Object.keys(cfg)) {
|
||||||
|
if(cfg[key].uri == uri) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
get_data_json(uri: string): string {
|
||||||
|
let found: boolean = false;
|
||||||
|
let data: string = '{';
|
||||||
|
let dp;
|
||||||
|
for(const key of Object.keys(cfg)) {
|
||||||
|
if(cfg[key].uri == uri) {
|
||||||
|
found = true;
|
||||||
|
dp = cfg[key];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let add_comma: boolean = false;
|
||||||
|
let o = Object.keys(dp);
|
||||||
|
o.forEach(d => {
|
||||||
|
let s = this.db.get(dp[d]);
|
||||||
|
if(s != null) {
|
||||||
|
if(add_comma) {
|
||||||
|
data += ","
|
||||||
|
}
|
||||||
|
data += '"' + d + '":"' + s + '"';
|
||||||
|
add_comma = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
data += '}';
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
27
Server/Source/DataRequester.ts
Normal file
27
Server/Source/DataRequester.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { IncomingMessage, request } from "http";
|
||||||
|
import { Database } from "./LocalDatabase";
|
||||||
|
|
||||||
|
export function request_data(id: string, self: &Database): void {
|
||||||
|
let url: string = 'http://192.168.178.34:8082/getBulk/' + id;
|
||||||
|
let data: string = "";
|
||||||
|
|
||||||
|
let req = request(url, (res: IncomingMessage) => {
|
||||||
|
res.setEncoding('utf8');
|
||||||
|
|
||||||
|
res.on('data', (chunk) => {
|
||||||
|
data += chunk;
|
||||||
|
});
|
||||||
|
|
||||||
|
res.on('end', () => {
|
||||||
|
let d = JSON.parse(data);
|
||||||
|
d.forEach(element => {
|
||||||
|
self.add(element.id, element.val)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', (e) => {
|
||||||
|
console.error(`problem with request: ${e.message}`);
|
||||||
|
});
|
||||||
|
req.end();
|
||||||
|
}
|
70
Server/Source/FileHandler.ts
Normal file
70
Server/Source/FileHandler.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import { existsSync, readFileSync } from 'node:fs';
|
||||||
|
|
||||||
|
interface Mapping {
|
||||||
|
ending: string;
|
||||||
|
encoding: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class File {
|
||||||
|
type: string;
|
||||||
|
content: Buffer;
|
||||||
|
|
||||||
|
constructor(type: string, content: Buffer) {
|
||||||
|
this.content = content;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FileHandler {
|
||||||
|
|
||||||
|
private www_folder: string = '/home/carsten/Dokumente/SmartHomeDashboard/html/';
|
||||||
|
private index_alias: string = 'index.html';
|
||||||
|
|
||||||
|
private mappings: Mapping[] = [
|
||||||
|
{ ending: 'html', encoding: 'text/html' },
|
||||||
|
{ ending: 'js', encoding: 'text/javascript' },
|
||||||
|
{ ending: 'css', encoding: 'text/css' },
|
||||||
|
{ ending: 'json', encoding: 'application/json' },
|
||||||
|
{ ending: 'ico', encoding: 'image/x-icon' },
|
||||||
|
{ ending: 'svg', encoding: 'image/svg+xml' },
|
||||||
|
{ ending: 'txt', encoding: 'text/plain' },
|
||||||
|
{ ending: 'png', encoding: 'image/png' },
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
file_allowed(url: string): boolean {
|
||||||
|
let allowed: boolean = false;
|
||||||
|
let m = url.match('\\.\\.');
|
||||||
|
if (m == null) {
|
||||||
|
allowed = true;
|
||||||
|
}
|
||||||
|
return allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_exists(url: string): boolean {
|
||||||
|
if(url == '/') {
|
||||||
|
url = this.index_alias;
|
||||||
|
}
|
||||||
|
return existsSync(this.www_folder + url);
|
||||||
|
}
|
||||||
|
|
||||||
|
file_get(url: string): File {
|
||||||
|
if(url == '/') {
|
||||||
|
url = this.index_alias;
|
||||||
|
}
|
||||||
|
return new File(this.get_type(url), readFileSync(this.www_folder + url));
|
||||||
|
}
|
||||||
|
|
||||||
|
private get_type(url: string): string {
|
||||||
|
if(url == '/') {
|
||||||
|
url = this.index_alias;
|
||||||
|
}
|
||||||
|
let type: string = 'application/octet-stream';
|
||||||
|
let m: Mapping = this.mappings.find((e) => e.ending == url.split('.').pop());
|
||||||
|
if(m != undefined) {
|
||||||
|
type = m.encoding;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
63
Server/Source/LocalDatabase.ts
Normal file
63
Server/Source/LocalDatabase.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import { Config, cfg } from "./Config";
|
||||||
|
import { request_data } from "./DataRequester";
|
||||||
|
|
||||||
|
export class Database {
|
||||||
|
private db: Datapoint[] = [];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
let groups = Object.keys(cfg);
|
||||||
|
groups.forEach(group => {
|
||||||
|
let members = Object.keys(cfg[group]);
|
||||||
|
members.forEach(member => {
|
||||||
|
if((member != "text") && (member != "uri")) {
|
||||||
|
this.add(cfg[group][member])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
add(id: string, value?: string, type?: string): void {
|
||||||
|
let found: boolean = false;
|
||||||
|
this.db.forEach(element => {
|
||||||
|
if(element.id == id) {
|
||||||
|
element.value = value;
|
||||||
|
element.type = type
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(!found) {
|
||||||
|
this.db.push(new Datapoint(id, value, type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get(id: string): string {
|
||||||
|
for(const el of this.db) {
|
||||||
|
if(el.id == id) {
|
||||||
|
return el.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
start(): void {
|
||||||
|
setInterval(this.cyclic_requets, 1000, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
cyclic_requets(self: &Database): void {
|
||||||
|
self.db.forEach(element => {
|
||||||
|
request_data(element.id, self)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Datapoint {
|
||||||
|
id: string;
|
||||||
|
value: string;
|
||||||
|
type: string;
|
||||||
|
|
||||||
|
constructor(id: string, value: string, type: string) {
|
||||||
|
this.id = id;
|
||||||
|
this.type = type;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
38
Server/Source/RequestHandler.ts
Normal file
38
Server/Source/RequestHandler.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { IncomingMessage, ServerResponse } from "node:http";
|
||||||
|
import { FileHandler, File } from "./FileHandler";
|
||||||
|
import { DataHandler } from "./DataHandler";
|
||||||
|
import { Database } from "./LocalDatabase";
|
||||||
|
|
||||||
|
export class RequestHandler {
|
||||||
|
static dh: DataHandler;
|
||||||
|
static fh: FileHandler;
|
||||||
|
|
||||||
|
constructor(db: &Database) {
|
||||||
|
RequestHandler.dh = new DataHandler(db);
|
||||||
|
RequestHandler.fh = new FileHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
new_request(req: IncomingMessage, res: ServerResponse): void {
|
||||||
|
if(RequestHandler.dh.valid_uri(req.url)) {
|
||||||
|
res.statusCode = 200;
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(RequestHandler.dh.get_data_json(req.url));
|
||||||
|
}
|
||||||
|
else if(RequestHandler.fh.file_allowed(req.url)) {
|
||||||
|
if(RequestHandler.fh.file_exists(req.url)) {
|
||||||
|
res.statusCode = 200;
|
||||||
|
let f: File = RequestHandler.fh.file_get(req.url)
|
||||||
|
res.setHeader('Content-Type', f.type);
|
||||||
|
res.end(f.content);
|
||||||
|
} else {
|
||||||
|
res.statusCode = 404;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.statusCode = 403;
|
||||||
|
}
|
||||||
|
if(res.statusCode != 200) {
|
||||||
|
console.log(req.url, res.statusCode);
|
||||||
|
}
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
}
|
22
Server/Source/Webserver.ts
Normal file
22
Server/Source/Webserver.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { createServer } from 'node:http'
|
||||||
|
import { RequestHandler } from './RequestHandler';
|
||||||
|
import { Database } from './LocalDatabase';
|
||||||
|
|
||||||
|
export class Webserver {
|
||||||
|
private port: number = 8080;
|
||||||
|
private hostname: string = '0.0.0.0';
|
||||||
|
private rh: RequestHandler;
|
||||||
|
|
||||||
|
constructor(db: &Database) {
|
||||||
|
this.rh = new RequestHandler(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
start_server(): void {
|
||||||
|
|
||||||
|
const server = createServer(this.rh.new_request);
|
||||||
|
|
||||||
|
server.listen(this.port, this.hostname, () => {
|
||||||
|
console.log('Server running at http://' + this.hostname + ':' + this.port);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
11
Server/Source/main.ts
Normal file
11
Server/Source/main.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { Webserver } from "./Webserver";
|
||||||
|
import { Database } from "./LocalDatabase";
|
||||||
|
|
||||||
|
let db = new Database();
|
||||||
|
let ws = new Webserver(db);
|
||||||
|
|
||||||
|
ws.start_server();
|
||||||
|
console.log("Server started");
|
||||||
|
|
||||||
|
db.start();
|
||||||
|
console.log("DB started");
|
@ -1,61 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.file_get = exports.file_exists = exports.file_allowed = exports.File = void 0;
|
|
||||||
var node_fs_1 = require("node:fs");
|
|
||||||
var Webserver_1 = require("./Webserver");
|
|
||||||
var Mapping = /** @class */ (function () {
|
|
||||||
function Mapping() {
|
|
||||||
}
|
|
||||||
return Mapping;
|
|
||||||
}());
|
|
||||||
var mappings = [
|
|
||||||
{ ending: 'html', encoding: 'text/html' },
|
|
||||||
{ ending: 'js', encoding: 'text/javascript' },
|
|
||||||
{ ending: 'css', encoding: 'text/css' },
|
|
||||||
{ ending: 'json', encoding: 'application/json' },
|
|
||||||
{ ending: 'ico', encoding: 'image/x-icon' },
|
|
||||||
{ ending: 'svg', encoding: 'image/svg+xml' },
|
|
||||||
{ ending: 'txt', encoding: 'text/plain' },
|
|
||||||
];
|
|
||||||
var File = /** @class */ (function () {
|
|
||||||
function File(type, content) {
|
|
||||||
this.content = content;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
return File;
|
|
||||||
}());
|
|
||||||
exports.File = File;
|
|
||||||
function file_allowed(url) {
|
|
||||||
var allowed = false;
|
|
||||||
var m = url.match('\\.\\.');
|
|
||||||
if (m == null) {
|
|
||||||
allowed = true;
|
|
||||||
}
|
|
||||||
return allowed;
|
|
||||||
}
|
|
||||||
exports.file_allowed = file_allowed;
|
|
||||||
function file_exists(url) {
|
|
||||||
if (url == '/') {
|
|
||||||
url = Webserver_1.index_alias;
|
|
||||||
}
|
|
||||||
return (0, node_fs_1.existsSync)(Webserver_1.www_folder + url);
|
|
||||||
}
|
|
||||||
exports.file_exists = file_exists;
|
|
||||||
function file_get(url) {
|
|
||||||
if (url == '/') {
|
|
||||||
url = Webserver_1.index_alias;
|
|
||||||
}
|
|
||||||
return new File(get_type(url), (0, node_fs_1.readFileSync)(Webserver_1.www_folder + url));
|
|
||||||
}
|
|
||||||
exports.file_get = file_get;
|
|
||||||
function get_type(url) {
|
|
||||||
if (url == '/') {
|
|
||||||
url = Webserver_1.index_alias;
|
|
||||||
}
|
|
||||||
var type = 'application/octet-stream';
|
|
||||||
var m = mappings.find(function (e) { return e.ending == url.split('.').pop(); });
|
|
||||||
if (m != undefined) {
|
|
||||||
type = m.encoding;
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"FileHandler.js","sourceRoot":"","sources":["../server/FileHandler.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,IAAM,UAAU,GAAW,iDAAiD,CAAA;AAC5E,IAAM,WAAW,GAAW,YAAY,CAAA;AAExC,SAAgB,YAAY,CAAC,GAAW;IACpC,IAAI,OAAO,GAAY,KAAK,CAAC;IAC7B,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1B,OAAO,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAND,oCAMC;AAED,SAAgB,WAAW,CAAC,GAAW;IACnC,OAAO,IAAA,oBAAU,EAAC,UAAU,GAAG,GAAG,CAAC,CAAC;AACxC,CAAC;AAFD,kCAEC"}
|
|
@ -1,23 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.new_request = void 0;
|
|
||||||
var FileHandler_1 = require("./FileHandler");
|
|
||||||
function new_request(req, res) {
|
|
||||||
if ((0, FileHandler_1.file_allowed)(req.url)) {
|
|
||||||
if ((0, FileHandler_1.file_exists)(req.url)) {
|
|
||||||
res.statusCode = 200;
|
|
||||||
var f = (0, FileHandler_1.file_get)(req.url);
|
|
||||||
res.setHeader('Content-Type', f.type);
|
|
||||||
res.end(f.content);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
res.statusCode = 404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
res.statusCode = 403;
|
|
||||||
}
|
|
||||||
console.log(req.url, res.statusCode);
|
|
||||||
res.end();
|
|
||||||
}
|
|
||||||
exports.new_request = new_request;
|
|
@ -1,16 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.start_server = exports.index_alias = exports.www_folder = void 0;
|
|
||||||
var node_http_1 = require("node:http");
|
|
||||||
var RequestHandler_1 = require("./RequestHandler");
|
|
||||||
exports.www_folder = '/home/carsten/Dokumente/SmartHomeDashboard/html/';
|
|
||||||
exports.index_alias = 'index.html';
|
|
||||||
var port = 8080;
|
|
||||||
var hostname = '0.0.0.0';
|
|
||||||
function start_server() {
|
|
||||||
var server = (0, node_http_1.createServer)(RequestHandler_1.new_request);
|
|
||||||
server.listen(port, hostname, function () {
|
|
||||||
console.log('Server running at http://' + hostname + ':' + port);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.start_server = start_server;
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"Webserver.js","sourceRoot":"","sources":["../server/Webserver.ts"],"names":[],"mappings":""}
|
|
@ -1,5 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var Webserver_1 = require("./Webserver");
|
|
||||||
(0, Webserver_1.start_server)();
|
|
||||||
console.log("Server started");
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../server/main.ts"],"names":[],"mappings":""}
|
|
@ -1,62 +0,0 @@
|
|||||||
import { existsSync, readFileSync } from 'node:fs';
|
|
||||||
import { www_folder, index_alias } from './Webserver';
|
|
||||||
|
|
||||||
class Mapping {
|
|
||||||
ending: string;
|
|
||||||
encoding: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mappings: Mapping[] = [
|
|
||||||
{ ending: 'html', encoding: 'text/html' },
|
|
||||||
{ ending: 'js', encoding: 'text/javascript' },
|
|
||||||
{ ending: 'css', encoding: 'text/css' },
|
|
||||||
{ ending: 'json', encoding: 'application/json' },
|
|
||||||
{ ending: 'ico', encoding: 'image/x-icon' },
|
|
||||||
{ ending: 'svg', encoding: 'image/svg+xml' },
|
|
||||||
{ ending: 'txt', encoding: 'text/plain' },
|
|
||||||
]
|
|
||||||
|
|
||||||
export class File {
|
|
||||||
type: string;
|
|
||||||
content: Buffer;
|
|
||||||
|
|
||||||
constructor(type: string, content: Buffer) {
|
|
||||||
this.content = content;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function file_allowed(url: string): boolean {
|
|
||||||
let allowed: boolean = false;
|
|
||||||
let m = url.match('\\.\\.');
|
|
||||||
if (m == null) {
|
|
||||||
allowed = true;
|
|
||||||
}
|
|
||||||
return allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function file_exists(url: string): boolean {
|
|
||||||
if(url == '/') {
|
|
||||||
url = index_alias;
|
|
||||||
}
|
|
||||||
return existsSync(www_folder + url);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function file_get(url: string): File {
|
|
||||||
if(url == '/') {
|
|
||||||
url = index_alias;
|
|
||||||
}
|
|
||||||
return new File(get_type(url), readFileSync(www_folder + url));
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_type(url: string): string {
|
|
||||||
if(url == '/') {
|
|
||||||
url = index_alias;
|
|
||||||
}
|
|
||||||
let type: string = 'application/octet-stream';
|
|
||||||
let m: Mapping = mappings.find((e) => e.ending == url.split('.').pop());
|
|
||||||
if(m != undefined) {
|
|
||||||
type = m.encoding;
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
import { IncomingMessage, ServerResponse } from "node:http";
|
|
||||||
import { file_allowed, file_exists, file_get, File } from "./FileHandler";
|
|
||||||
|
|
||||||
export function new_request(req: IncomingMessage, res: ServerResponse): void {
|
|
||||||
if(file_allowed(req.url)) {
|
|
||||||
if(file_exists(req.url)) {
|
|
||||||
res.statusCode = 200;
|
|
||||||
let f: File = file_get(req.url)
|
|
||||||
res.setHeader('Content-Type', f.type);
|
|
||||||
res.end(f.content);
|
|
||||||
} else {
|
|
||||||
res.statusCode = 404;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res.statusCode = 403;
|
|
||||||
}
|
|
||||||
console.log(req.url, res.statusCode);
|
|
||||||
res.end();
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
import { createServer } from 'node:http'
|
|
||||||
import { new_request } from './RequestHandler';
|
|
||||||
|
|
||||||
|
|
||||||
export const www_folder: string = '/home/carsten/Dokumente/SmartHomeDashboard/html/';
|
|
||||||
export const index_alias: string = 'index.html';
|
|
||||||
const port: number = 8080;
|
|
||||||
const hostname: string = '0.0.0.0';
|
|
||||||
|
|
||||||
|
|
||||||
export function start_server(): void {
|
|
||||||
const server = createServer(new_request);
|
|
||||||
|
|
||||||
server.listen(port, hostname, () => {
|
|
||||||
console.log('Server running at http://' + hostname + ':' + port);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
import { start_server } from "./Webserver";
|
|
||||||
|
|
||||||
start_server();
|
|
||||||
console.log("Server started");
|
|
@ -8,6 +8,6 @@
|
|||||||
"outDir": "scripts"
|
"outDir": "scripts"
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"server/**/*"
|
"Source/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
21
html/design.css
Normal file
21
html/design.css
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: Lobster-Regular;
|
||||||
|
src: url(/fonts/Lobster-Regular.ttf);
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: Lobster-Regular;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-image: url(/ostsee.jpg);
|
||||||
|
background-size: cover;
|
||||||
|
margin: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
top: 0;
|
||||||
|
position: absolute;
|
||||||
|
}
|
BIN
html/fonts/Lobster-Regular.ttf
Normal file
BIN
html/fonts/Lobster-Regular.ttf
Normal file
Binary file not shown.
93
html/fonts/OFL.txt
Normal file
93
html/fonts/OFL.txt
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2010 The Lobster Project Authors (https://github.com/impallari/The-Lobster-Font), with Reserved Font Name "Lobster".
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
BIN
html/images/Altpapier.png
Normal file
BIN
html/images/Altpapier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
html/images/Biotonne.png
Normal file
BIN
html/images/Biotonne.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
html/images/Gelbetonne.png
Normal file
BIN
html/images/Gelbetonne.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
html/images/Restabfall.png
Normal file
BIN
html/images/Restabfall.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
@ -1,5 +1,11 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<script src="/scripts/main.js"></script>
|
<head>
|
||||||
Hat geklappt
|
<script src="/scripts/main.js"></script>
|
||||||
</html>
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||||
|
<link rel="stylesheet" href="/design.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Hat geklappt
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
BIN
html/ostsee.jpg
Normal file
BIN
html/ostsee.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 MiB |
Reference in New Issue
Block a user