Skip to content

jasiukiewicztymon/websrv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Websrv

Websrv, is a static website server for localhost testing, that can use HTTP and HTTPS. Your files have to be put inside the /public, and don't forget to fill in the .env.example.

Getting started

git clone https://github.com/jasiukiewicztymon/websrv.git
cd websrv
npm i
node .

SSL

To generate the localhost SSL certificate, use this command:

openssl req -x509 -out localhost.crt -keyout localhost.key   -newkey rsa:2048 -nodes -sha256   -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Websocket scripts

WS (http)

<script>
     const exampleSocket = new WebSocket(
             "ws://localhost:8090/"
         );
         exampleSocket.onmessage = (event) => {
             window.location.reload();
         };
 </script>

WSS (https)

<script>
     const exampleSocket = new WebSocket(
             "wss://localhost:8091/"
         );
         exampleSocket.onmessage = (event) => {
             window.location.reload();
         };
 </script>

To-do

  • Realtime changes reload