const express = require('express');
const cors = require('cors');
// env
const port = process.env.PORT || 3000;
// server
const app = express();
app.use(cors());
// routes
app.get('/', (req, res) => {
res.send('Hello World!');
});
// start
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
///////////////////////////////////////////
// https
/*
npm install -g mkcert
mkcert create-ca
mkcert create-cert
const https = require("https");
const fs = require("fs");
const options = {
key: fs.readFileSync("./config/cert.key"),
cert: fs.readFileSync("./config/cert.crt"),
};
https.createServer(options, app).listen(8080, () => {
console.log(`HTTPS server started on port 8080`);
});
*/
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter