Quote API Cannot get /

I just started working on the Quote API project from the back end development path. And I’m trying to run in on my own PC but when I load the localhost:4001 page it just logs “Cannot get /” in the browser. But the same code does run in the codecademy envirement. I can always just finish it on codecademy but I prefer working in VSCODE. Thank for the help in advance. This is the code I’m running:

const express = require(‘express’);
const morgan = require(‘morgan’);
const app = express();

const { quotes } = require(‘./data’);

const { getRandomElement } = require(‘./utils’);

const PORT = process.env.PORT || 4001;

app.use(express.static(‘public’));

app.listen(PORT, () => {
console.log(Listening on ${PORT})
})

Keep in my mind is does work on codecademy but not in my own browser. I just the npm install command before hand and in the console it does log that it is listening on the port.

Are you starting the server via the appropriate terminal command first? e.g. ‘node server.js’

1 Like

Yes first the server isn’t running so I get the can’t get connection thing. Then I run node node server.js and it shows cannot get /

Okay, so the next step is that in order for a server to GET something, there has to be a GET response. Is it still logging its listening message to the console? By the way, the text inside console.log() should be encompassed by backticks like this ‘Listening on ${PORT}’

I’m sorry for wasting your time. I found out that I didn’t download the HTML & CSS files (I have no idea how this happened). Thank you for the trouble anyways everything is working now.