|
@@ -5,8 +5,8 @@ const server = http.createServer();
|
|
|
|
|
|
const mime = {
|
|
|
'.html': 'text/html',
|
|
|
- '.css' : 'text/css',
|
|
|
- '.jpg' : 'image/jpeg',
|
|
|
+ '.css' : 'text/css',
|
|
|
+ '.jpg' : 'image/jpeg',
|
|
|
'.js' : 'application/javascript',
|
|
|
};
|
|
|
|
|
@@ -17,15 +17,15 @@ server.on( 'request', async ( request, response ) => {
|
|
|
if ( url === '/' ) {
|
|
|
fullPath = path.resolve( './src/js/test/html/index.html' );
|
|
|
} else if ( url.startsWith( '/' ) ) {
|
|
|
- fullPath = path.resolve( `.${ url }` );
|
|
|
+ fullPath = path.resolve( `.${ url }` );
|
|
|
} else {
|
|
|
fullPath = url;
|
|
|
}
|
|
|
|
|
|
- const type = mime[ path.extname( fullPath ) ] || 'text/plain';
|
|
|
- const buffer = await fs.readFile( fullPath ).catch( e => console.warn( e ) );
|
|
|
+ const type = mime[ path.extname( fullPath ) ] || 'text/plain';
|
|
|
+ const buffer = await fs.readFile( fullPath ).catch( e => console.warn( e ) );
|
|
|
|
|
|
- response.writeHead( 200, { 'Content-Type': type } );
|
|
|
+ response.writeHead( 200, { 'Content-Type': type } );
|
|
|
response.end( buffer );
|
|
|
} );
|
|
|
|