├── package.json
├── package-lock.json
├── public
│ └── css
│ └── style.css
├── README.md
├── server.js
└── views
└── index.ejs
var express = require('express');
var app = express();
// set the port of our application
// process.env.PORT lets the port be set by Heroku
var port = process.env.PORT || 8080;
// set the view engine to ejs
app.set('view engine', 'ejs');
// make express look in the public directory for assets (css/js/img)
app.use(express.static(__dirname + '/public'));
// set the home page route
app.get('/', function(req, res) {
// ejs render automatically looks in the views folder
res.render('index');
});
app.listen(port, function() {
console.log('Our app is running on http://localhost:' + port);
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Node Sample App</title>
<!-- CSS -->
<!-- load bootstrap and our own personal stylesheet -->
<link href="//maxcdn.bootstrapcdn.com/bootswatch/3.2.0/superhero/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>This Is Heroku App</h1<
<p><a href="https://ylparth.blogspot.com" class="btn btn-primary btn-lg">read more blogs</a></p>
</div>
</div>
</body>
</html>
body { padding-top:50px; }
.container .jumbotron { border-radius:40px; }
{
"name": "heroku-node",
"description": "Our sample Node to Heroku app",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"ejs": "~1.0.0",
"express": "^4.17.1"
}
}
# reading-list1
push your code in existing git repository 'repo1' from the command line
$ git clonewe require heroku account
$ heroku loginsimple setup for connect github with heroku
- goto heroku site > login
0 Comments