Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

65 lines
1.4 KiB

/**
* @author Jeffery Russell 8-19-18
*/
//used for file IO
const utils = require('../utils/utils.js');
//used for static files
const includes = require('../includes/includes');
//for parsing post data
const qs = require('querystring');
const processContactPage = function(request)
{
return new Promise(function(resolve, reject)
{
utils.getPostData(request).then(function(postData)
{
const data = qs.parse(postData);
console.log(postData);
console.log(data);
if(data.name && data.email)
{
//send email
resolve(utils.include("includes/messageSent.html"));
}
else
{
resolve(utils.include("includes/contact.html"));
}
}).catch(function(err)
{
reject(err);
})
});
};
module.exports =
{
main: function(request, result)
{
result.writeHead(200, {'Content-Type': 'text/html'});
Promise.all([includes.printAdminHeader(),
processContactPage(request),
require("../sidebar/sidebar.js").main(),
includes.printFooter()]).then(function(content)
{
result.write(content.join(''));
result.end();
}).catch(function(err)
{
console.log(err);
});
}
};