diff --git a/includes/projects.js b/includes/projects.js index 9529f24..22c545e 100644 --- a/includes/projects.js +++ b/includes/projects.js @@ -1,9 +1,6 @@ //file io const utils = require('../utils/utils.js'); -//DB queries -const sql = require('../utils/sql'); - //used to parse the request URL const url = require('url'); @@ -21,13 +18,17 @@ module.exports= * @param requestURL * @returns {Promise|*} */ - main: function(request, result) + main: function(request, result, baseURL) { //const filename = url.parse(request.url, true).pathname var filename = url.parse(request.url, true).pathname; - if(filename.includes("/img/") || filename.includes(".jpg") || + if(filename.includes(".svg") || filename.includes(".svg")) + { + result.writeHead(200, {'Content-Type': 'image/svg+xml'}); + } + else if(filename.includes("/img/") || filename.includes(".jpg") || filename.includes(".png") || filename.includes(".ico")) { result.writeHead(200, {'Content-Type': 'image/png'}); @@ -46,9 +47,9 @@ module.exports= result.writeHead(200, {'Content-Type': 'text/html'}); } - if(filename == "/steam" || filename == "/steam/") + if(filename == baseURL || filename == baseURL.substring(0, baseURL.length - 1)) { - filename = "/steam/index.html"; + filename = baseURL + "index.html"; } utils.include("./blogContent/projects" + filename).then(function(content) diff --git a/server.js b/server.js index 63aaee5..b2cbd6d 100644 --- a/server.js +++ b/server.js @@ -37,6 +37,7 @@ map.main(); //port for the server to run on const port = 8000; +const projects = ["/steam/"]; /** * Parses the request url and calls correct JS files @@ -49,15 +50,26 @@ app.use(function(request, result) { const filename = url.parse(request.url, true).pathname; + var project = false; + projects.forEach(function(projectName) + { + if(filename.includes(projectName)) + { + require("./includes/projects.js").main(request, result, projectName); + project = true; + } + }); + - if (filename.includes("/steam/")) + if(project) { - require("./includes/projects.js").main(request, result); + //don't do blog stuff } //handles image requests else if(filename.includes("/img/") || filename.includes(".jpg") || - filename.includes(".png") || filename.includes(".ico")) + filename.includes(".png") || filename.includes(".ico") + || filename.includes(".svg")) { includes.sendImage(result, filename, cache); }