Fastes way to create a good looking webpage with node.js

If you need a responsive website to showcase something, here is a really fast way to do so.

Download a design you like from html5up.net.

$ mkdir node-html5
$ cd node-html5
$ npm init (just accept default settings)
$ npm install express --save

Extract the content of the design pack into the directory. Create index.js in the directory with the following content:

var express = require('express')
var path = require('path')
var PORT = 60000
var app = express()

app.use('/assets', express.static('assets'))
app.use('/images', express.static('images'))

app.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/index.html'))
})

app.listen(PORT, function () {
console.log('Listening on port: ' + PORT)
})

The directory should look like this:

../node-html5/
├── assets
├── images
├── index.html
├── index.js
├── node_modules
├── package.json

Now edit the html, css and images like you want to.
Start the webserver with

$ node index.js

and point your browser to http://localhost:60000.

To deploy this setup e.g. to uberspace, see this post.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.