Hướng dẫn hbs nodejs - hbs nodejs
Ngày đăng:
11/11/2022
Trả lời:
0
Lượt xem:
34
1. Framework ExpressJS Show
Cài đặt:
Cấu trúc của ExpressJSNhư các bạn thấy trên hình, Cấu trúc của express js vô cùng đơn giản.
2. Template Engine Handlebars
Cài đặt
Config Handlebars trong Project
3. Xây dựng ứng dụng NodeJS.3.1. Tạo trang viewConfig ban đầu để thực hiện connect với PostgreSQL
database: database name kết nối. password: mật khẩu database. Tiến hành connect với DB để thực hiện get data từ table để hiển thị lên page.
3.2. Tạo trang thêm
router.get('/', function(req, res, next) method get dùng để hiển thị page add. router.post('/', urlencodedParser, function (req, res) method post nhận dữ liệu submit từ client lên server. 3.3. Tạo trang sửa
router.get('/:id', function(req, res, next) method get theo id từ page request update. Link source: https://github.com/JAV-DN-team/NodeJS_CRUD_Passport_HieuPV |