Ignoriere Scripts Ordner (generierte Dateien)

This commit is contained in:
Carsten Keller 2024-02-16 18:46:58 +01:00
parent 3975490017
commit afaa27a0ea
Signed by: carsten
GPG Key ID: F120DCD2D6C1CC54
7 changed files with 0 additions and 108 deletions

View File

@ -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;
}

View File

@ -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"}

View File

@ -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;

View File

@ -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;

View File

@ -1 +0,0 @@
{"version":3,"file":"Webserver.js","sourceRoot":"","sources":["../server/Webserver.ts"],"names":[],"mappings":""}

View File

@ -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");

View File

@ -1 +0,0 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../server/main.ts"],"names":[],"mappings":""}