<commit_before>'use strict';

var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

var express = require('express');
var app = express();

app.get('/', function(req,res) {
	res.end('Add a string to the end of the URL to use the microservice...\n\nFor example: \n\nhttps://timestamp-hamptonjt.c9users.io/April%2011,%201977')
	
})

app.get('/:date', function(req, res) {
	var timestamp = {
		"unix": null,
		"natural": null
	}
	
	var inputDate = req.params.date
	var inputDateAsDate = new Date()
	var d = Date.parse(inputDate)
	var naturalDate
	
	inputDateAsDate.setTime(inputDate * 1000) // convert to milliseconds...
	
	res.writeHead(200, {'Accept': 'application/json'})
	
	if ( isNaN(d) ) {  
		// date is not valid as a natural date - check to see if it was a unix date..
		d = inputDateAsDate
		var unixDate = Date.parse(d)
		if ( isNaN(unixDate) ) {
			// date is invalid
			timestamp.unix = null
			timestamp.natural = null
			console.log('Invalid Date by time...')
			res.end(JSON.stringify(timestamp))
		}
		else {
			// date is valid...
			naturalDate = new Date(unixDate)
			timestamp.unix = inputDate 
			timestamp.natural = months[naturalDate.getMonth()] + ' ' + naturalDate.getDate() + ', ' + naturalDate.getFullYear()
			res.end(JSON.stringify(timestamp))
		}
	}
	else {
		// date is valid
		naturalDate = new Date(d)
		timestamp.unix = d / 1000
		timestamp.natural = months[naturalDate.getMonth()] + ' ' + naturalDate.getDate() + ', ' + naturalDate.getFullYear()
		res.end(JSON.stringify(timestamp))
	}
	
	console.log('Input Date:', inputDate)
	console.log('Unix:', timestamp.unix)
	console.log('Natural:', timestamp.natural)
})

var port = process.env.PORT || 8080;
app.listen(port,  function () {
	console.log('Node.js listening on port ' + port + '...');
});<commit_msg>Fixing the 'index' page to deliver HTML and fix the link for heroku instead of c9<commit_after>'use strict';

var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

var express = require('express');
var app = express();

app.get('/', function(req,res) {
	res.writeHead(200, {'content-type': 'text/html'})
	res.end('<h1>API Basejump: Timestamp Microservice</h1>Add a string to the end of the URL to use the microservice...<br>&nbsp;</br>For example: <br>&nbsp;</br>https://nameless-woodland-23183.herokuapp.com/April%2011,%201977')
	
})

app.get('/:date', function(req, res) {
	var timestamp = {
		"unix": null,
		"natural": null
	}
	
	var inputDate = req.params.date
	var inputDateAsDate = new Date()
	var d = Date.parse(inputDate)
	var naturalDate
	
	inputDateAsDate.setTime(inputDate * 1000) // convert to milliseconds...
	
	res.writeHead(200, {'Accept': 'application/json'})
	
	if ( isNaN(d) ) {  
		// date is not valid as a natural date - check to see if it was a unix date..
		d = inputDateAsDate
		var unixDate = Date.parse(d)
		if ( isNaN(unixDate) ) {
			// date is invalid
			timestamp.unix = null
			timestamp.natural = null
			console.log('Invalid Date by time...')
			res.end(JSON.stringify(timestamp))
		}
		else {
			// date is valid...
			naturalDate = new Date(unixDate)
			timestamp.unix = inputDate 
			timestamp.natural = months[naturalDate.getMonth()] + ' ' + naturalDate.getDate() + ', ' + naturalDate.getFullYear()
			res.end(JSON.stringify(timestamp))
		}
	}
	else {
		// date is valid
		naturalDate = new Date(d)
		timestamp.unix = d / 1000
		timestamp.natural = months[naturalDate.getMonth()] + ' ' + naturalDate.getDate() + ', ' + naturalDate.getFullYear()
		res.end(JSON.stringify(timestamp))
	}
	
	console.log('Input:', inputDate)
	console.log('Unix:', timestamp.unix)
	console.log('Natural:', timestamp.natural)
})

var port = process.env.PORT || 8080;
app.listen(port,  function () {
	console.log('Node.js listening on port ' + port + '...');
});
{'fraction_non_alphanumeric': 0.16844783715012723, 'fraction_numerical': 0.015776081424936386, 'mean_word_length': 3.8115055079559363, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4344619', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1316, 'n_words': 326}