Hey, I’m creating a website on glitch however whenever I try to open the website I have to put the file extension into the URL, for example: www.example.com/example.html. I was wondering if there is any way of removing this from the URL so it becomes: www.example.com/example
1 Like
Hello.
First of all, your project is must be hello-node
. Then, you can use express
npm module and insert this code to main file:
const Express = require ('express'),
Application = Express ()
Application.get ('/', (Request, Response) => { /* You can edit '/' part, for ex. as '/example' */
Response.sendFile (__dirname + '/example-folder/example.html')
})
Application.listen (3000, () => {
console.log ('Hello World!')
})
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.