Question:
please how can I get my live app url on replit? it’s not showing the link it just keeps loading…
** https://replit.com/@eosemudiamen990/Emmanuels-project-from-Engine194sCode?s=app **
// where your node app starts
// Init project
var express = require('express');
var app = express();
// Enable CORS
// So that your Api is remotely testable by fcc
var cors = require('cors');
app.use(cors({optionsSuccessStatus: 200})); //some legacy browsers choke 204
// http://expressjs.com/en/starter/static -files.html
app.use(express.static('public'));
//http://expressjs.com/en/starter/basic/routing.html
app.get("/", function (req, res) {
res.sendFile(__dirname + '/views/index.html');
});
const isInvalidDate = (date) => date.toUTCstring( ) === "Invalid Date"
// your first Api endpoint
app.get("/api/hello", function (req, res) {
let date = req.params.date;
let unixDate;
let dateObj;
let utcDate;
// Test whether the input date is a number
let isUnix = /^\d+$/.test(date);
// If no date is specified use the current date
if (!date) {
dateObj = new Date();
}
// If the date is a unix timestamp
else if (date && isUnix) {
unixDate = parseint(date);
dateObj = new Date(unixDate);
}
// if the date is not a unix timestamp
else if (date && !isUnix) {
dateObj = new Date(date);
}
if (dateObj.toString() === "Invalid Date") {
res.json({error: "Invalid Date"});
return;
}
unixDate = dateObj.getTime( );
utcDate = dateObj.toUTCString;
res.json({unix: unixDate, utc: utcDate});
});
// listening for requests : )
var listener = app.listen(process.env.PORT, function () {
console.log('Your app is listening on port ' + listener.address().port);
});