Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

https with express

const fs = require('fs');
const https = require('https');

const app = require('express')();
app.get('*', (req, res) => res.send('<h1>Hello, World</h1>'));

const server = https.createServer({
  key: fs.readFileSync(`${__dirname}/localhost-key.pem`, 'utf8'),
  cert: fs.readFileSync(`${__dirname}/localhost.pem`, 'utf8')
}, app);

await server.listen(443);
Comment

https express

var express = require("express");
var fs = require("fs");
var https = require("https");
var app = express();

app.get("/", function (req, res) {
  res.send("hello world");
});

https
  .createServer(
    {
      key: fs.readFileSync("server.key"),
      cert: fs.readFileSync("server.cert"),
    },
    app
  )
  .listen(3000, function () {
    console.log(
      "Example app listening on port 3000! Go to https://localhost:3000/"
    );
  });
Comment

PREVIOUS NEXT
Code Example
Javascript :: js reverse a strings in array 
Javascript :: merg two array js 
Javascript :: react code 
Javascript :: js sort strings lowercase and uppercase 
Javascript :: typescript get class list for element 
Javascript :: MONGOOSE update on by body 
Javascript :: how to get the last two characters of a string in javascript 
Javascript :: how to write a variable in js 
Javascript :: javascript count up timer 
Javascript :: js decrease opacity canvas 
Javascript :: createelement add class 
Javascript :: password validation in angular 
Javascript :: lenght validation using jquey valisaton 
Javascript :: calculate two number and diplay next field without reload the page javascript 
Javascript :: for in javascript 
Javascript :: redux saga fetch data 
Javascript :: get yyyy-mm-dd hh:mm from date javascript 
Javascript :: transform date to relative date js 
Javascript :: Icons library in react 
Javascript :: javascript download image 
Javascript :: escape sequence in js 
Javascript :: npm react-device-detect 
Javascript :: how to delete object properties in javascript 
Javascript :: javascript save data to local storage 
Javascript :: quiz javascript example with array 
Javascript :: js origin without port 
Javascript :: array includes javascript 
Javascript :: vue compare two dates 
Javascript :: difference between normal function and arrow function 
Javascript :: javascript objects 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =