BackendStack21 / restana

Restana is a lightweight and fast Node.js framework for building RESTful APIs.
MIT License
467 stars 27 forks source link

Send HTML file with specific route #61

Closed neumartin closed 4 years ago

neumartin commented 4 years ago

Hi!

Im using serve-static to serve static files with restana, but I need to specify the route and trim ".html" part. For example the url http://localhost:3000/login.html I need to convert into http://localhost:3000/login

How can I do it? Thanks!

neumartin commented 4 years ago

Finally I do this:

        .get('/login', async (req, res) => {
            let content = await fs.readFileSync(process.cwd() + "/public/" + "login.html");
            res.send(content);
        })

Maybe is not the best solution, but works.