mirror of
https://github.com/uNetworking/uWebSockets.js.git
synced 2025-12-19 18:10:26 -05:00
Add CachedHelloWorld.js example
This commit is contained in:
18
examples/CachedHelloWorld.js
vendored
Normal file
18
examples/CachedHelloWorld.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* Minimal SSL/non-SSL example using 5 seconds of HTTP cache */
|
||||||
|
|
||||||
|
const uWS = require('../dist/uws.js');
|
||||||
|
const port = 9001;
|
||||||
|
|
||||||
|
const app = uWS./*SSL*/App({
|
||||||
|
key_file_name: 'misc/key.pem',
|
||||||
|
cert_file_name: 'misc/cert.pem',
|
||||||
|
passphrase: '1234'
|
||||||
|
}).get('/*', (res, req) => {
|
||||||
|
res.end('Hello World!');
|
||||||
|
}, 5).listen(port, (token) => {
|
||||||
|
if (token) {
|
||||||
|
console.log('Listening to port ' + port);
|
||||||
|
} else {
|
||||||
|
console.log('Failed to listen to port ' + port);
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user