|
@ -7,6 +7,8 @@ |
|
|
|
|
|
|
|
|
const http = require('http'); |
|
|
const http = require('http'); |
|
|
|
|
|
|
|
|
|
|
|
var https = require('https'); |
|
|
|
|
|
|
|
|
const url = require('url'); |
|
|
const url = require('url'); |
|
|
|
|
|
|
|
|
var express = require("express"); |
|
|
var express = require("express"); |
|
@ -15,8 +17,23 @@ var session = require('express-session'); |
|
|
|
|
|
|
|
|
const includes = require('./includes/includes.js'); |
|
|
const includes = require('./includes/includes.js'); |
|
|
|
|
|
|
|
|
|
|
|
var forceSsl = require('express-force-ssl'); |
|
|
|
|
|
|
|
|
var app = express(); |
|
|
var app = express(); |
|
|
|
|
|
|
|
|
|
|
|
var fs = require('fs'); |
|
|
|
|
|
|
|
|
|
|
|
//var key = fs.readFileSync('private.key');
|
|
|
|
|
|
//var cert = fs.readFileSync( 'primary.crt' );
|
|
|
|
|
|
//var ca = fs.readFileSync( 'encryption/intermediate.crt' );
|
|
|
|
|
|
|
|
|
|
|
|
// var options = {
|
|
|
|
|
|
// key: key,
|
|
|
|
|
|
// cert: cert,
|
|
|
|
|
|
// ca: ca
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
//the secret is different on production
|
|
|
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 6000000 }})); |
|
|
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 6000000 }})); |
|
|
|
|
|
|
|
|
app.use(function(request, res) |
|
|
app.use(function(request, res) |
|
@ -25,7 +42,7 @@ app.use(function(request, res) |
|
|
var filename = q.pathname; |
|
|
var filename = q.pathname; |
|
|
|
|
|
|
|
|
//handles image requests
|
|
|
//handles image requests
|
|
|
if(filename.includes("/img/")) |
|
|
|
|
|
|
|
|
if(filename.includes("/img/") || filename.includes(".jpg")) |
|
|
{ |
|
|
{ |
|
|
require("./img/image.js").main(res, filename); |
|
|
require("./img/image.js").main(res, filename); |
|
|
} |
|
|
} |
|
@ -38,7 +55,7 @@ app.use(function(request, res) |
|
|
var file = ""; |
|
|
var file = ""; |
|
|
|
|
|
|
|
|
if(filename === '' || filename === '/') |
|
|
if(filename === '' || filename === '/') |
|
|
filename = '/category/Java'; |
|
|
|
|
|
|
|
|
filename = '/category/projects'; |
|
|
|
|
|
|
|
|
var urlSplit = filename.split("/"); |
|
|
var urlSplit = filename.split("/"); |
|
|
|
|
|
|
|
@ -62,7 +79,10 @@ app.use(function(request, res) |
|
|
//console.log("fin"); //for debugging
|
|
|
//console.log("fin"); //for debugging
|
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
http.createServer(app).listen(8080); |
|
|
|
|
|
|
|
|
//https.createServer(options, app).listen(443);
|
|
|
|
|
|
|
|
|
|
|
|
http.createServer(app).listen(80); |
|
|
|
|
|
|
|
|
|
|
|
//app.use(forceSsl);
|