I am currently working on rendering an HTML page using Express. Here is how my code looks so far:
const express = require('express');
const app = express();
app.use(express.static(__dirname + '/public'));
app.set('view engine', 'ejs');
app.listen(3000, function() {
console.log('Listening on PORT 3000');
})
app.get('/', function(req, res){
res.send('Home page!')
})
app.get('/events', function(req, res){
res.render('eventForm')
})
This is the current file structure of my project:
-Project
-node_modules
-public
index.html
-views
eventForm.html
I initially attempted to place the eventForm.html in the public
directory as well but for some reason my server is unable to locate it. The error message I receive is:
Error: Failed to lookup view "eventForm" in views directory "/Users/username/LearnProgramming/api_playground/stubhub/views"