@@ -34,12 +34,14 @@ const statik = require('node-static');
3434## Usage
3535
3636``` js
37+ import http from ' node:http' ;
38+
3739//
3840// Create a node-static server instance to serve the './public' folder
3941//
4042const file = new statik.Server (' ./public' );
4143
42- require ( ' http' ) .createServer (function (request , response ) {
44+ http .createServer (function (request , response ) {
4345 request .addListener (' end' , function () {
4446 //
4547 // Serve files!
@@ -82,11 +84,12 @@ To serve files under a directory, simply call the `serve` method on a `Server`
8284instance, passing it the HTTP request and response object:
8385
8486``` js
85- const statik = require (' node-static' );
87+ import http from ' node:http' ;
88+ import * as statik from ' node-static' ;
8689
87- var fileServer = new statik.Server (' ./public' );
90+ const fileServer = new statik.Server (' ./public' );
8891
89- require ( ' http' ) .createServer (function (request , response ) {
92+ http .createServer (function (request , response ) {
9093 request .addListener (' end' , function () {
9194 fileServer .serve (request, response);
9295 }).resume ();
@@ -108,7 +111,7 @@ For example, you could serve an error page, when the initial request wasn't
108111found:
109112
110113``` js
111- require ( ' http' ) .createServer (function (request , response ) {
114+ http .createServer (function (request , response ) {
112115 request .addListener (' end' , function () {
113116 fileServer .serve (request, response, function (e , res ) {
114117 if (e && (e .status === 404 )) { // If the file wasn't found
@@ -130,11 +133,12 @@ time a file has been served successfully, or if there was an error serving the
130133file:
131134
132135``` js
133- const statik = require (' node-static' );
136+ import http from ' node:http' ;
137+ import * as statik from ' node-static' ;
134138
135139const fileServer = new statik.Server (' ./public' );
136140
137- require ( ' http' ) .createServer (function (request , response ) {
141+ http .createServer (function (request , response ) {
138142 request .addListener (' end' , function () {
139143 fileServer .serve (request, response, function (err , result ) {
140144 if (err) { // There was an error serving the file
0 commit comments