Conversation with Gemini
Simple Json file call html file in same folder
JSON html file link
Package.json file has index.js file name
FBI,Facebook,blogger tricks, blogger tips, blogger tutorials, blogger widgets, SEO guide, make money online, css, html, jQuery tricks
Read More:
https://github.com/johnpapa/node-hello/blob/master/package.json
https://www.digitalocean.com/community/tutorials/how-to-use-ejs-to-template-your-node-application
Simple Json file call html file in same folder
JSON html file link
Package.json file has index.js file name
Hello/
├── index.js
├── index.ejs
└── package.json
index.ejs (The Template File)index.ejs file in the root folder and add this valid HTML/EJS code:<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EJS GitHub Template</title>
<style>
body { font-family: system-ui, sans-serif; background: #fafafa; color: #333; text-align: center; padding: 50px; }
.card { background: white; max-width: 400px; margin: 0 auto; padding: 20px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
h1 { color: #24292e; }
</style>
</head>
<body>
<div class="card">
<h1><%= title %></h1>
<p><%= message %></p>
</div>
</body>
</html>
index.js (The Server Code)EADDRINUSE error:const express = require('express');
const path = require('path');
const app = express();
// Use port 3001 if port 3000 is still blocked
const port = process.env.PORT || 3001;
app.set('view engine', 'ejs');
app.set('views', __dirname);
app.get('/', (req, res) => {
res.render('index', {
title: 'Hello GitHub!',
message: 'This simple template is rendering dynamically using Express and EJS.'
});
});
app.listen(port, () => {
console.log(`Server running successfully on http://localhost:${port}/`);
});
package.jsonindex.js:{
"name": "simple-ejs-template",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"ejs": "^3.1.10",
"express": "^5.2.1"
}
}
npm install in your terminal window.npm start.Simple Json file call html file in same folder
JSON html file link
Package.json file has index.js file name
https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets
0 comments:
Post a Comment