-1
I’m learning Ode.js, but I’m getting too caught up in establishing the routes correctly.
The structure of my folder is currently like this
The code of the file server.js is thus found:
const express = require('express')
const app = express()
const hbs = require('express-handlebars')
const path = require('path')
const pdf = require('html-pdf')
//template
//app.engine('handlebars',hbs())
app.engine('handlebars',hbs({
layoutsDir: __dirname + '/views/layouts',
}));
app.set('view engine', 'handlebars')
app.set('views', __dirname + '/views')
//app.set('views', path.join(__dirname, 'views'))
app.get('/', function(req, res){
res.render('home', {layout: 'main'})
pdf.create(home, options).toFile("conclusao.pdf", (err, data)=>{
return response.send("Erro ao gerar o PDF")
})
})
const discentes = [
{
name: "Suaziele Cristina de Souza",
age: 21,
courseData: "21/12/2020",
date: "10/06/2021",
obs: "Graduada em Ciência da Computaçâo."
},
];
app.listen(3000)
The intention was to connect the "home.handlebars" home page and display its content.
NOTE: the file "main.handlebars" has only this code
{{{body}}}
Thanks in advance for the attention of this community that has helped me so much and continues to help those who study programming.
pdf.create(
But here you want to convert a page into pdf. html page has a look at this respposta https://stackoverflow.com/a/37299711/6754506. And this home has not been declared anywhere else– adventistaam