File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,29 @@ if (fs.existsSync("data")) {
2525
2626const requestListener = function ( req , res ) {
2727 log ( req . url )
28-
28+ if ( req . url === "/test" ) {
29+ fs . readFile ( "templates/rick.html" , function ( err , data ) {
30+ if ( err ) {
31+ res . writeHead ( 404 ) ;
32+ res . end ( JSON . stringify ( err ) ) ;
33+ return ;
34+ }
35+ res . writeHead ( 200 ) ;
36+ res . end ( data ) ;
37+ } ) ;
38+ } else if ( req . url === "/" ) {
39+
40+ } else {
41+ fs . readFile ( "static" + req . url , function ( err , data ) {
42+ if ( err ) {
43+ res . writeHead ( 404 ) ;
44+ res . end ( JSON . stringify ( err ) ) ;
45+ return ;
46+ }
47+ res . writeHead ( 200 ) ;
48+ res . end ( data ) ;
49+ } ) ;
50+ }
2951}
3052
3153const server = http . createServer ( requestListener ) ;
Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < title > Test</ title >
4+ </ head >
5+ < body >
6+ < iframe height ="350 " width ="600 "
7+ src ="https://www.youtube.com/embed/dQw4w9WgXcQ ">
8+ </ iframe >
9+ </ body >
10+ </ html >
You can’t perform that action at this time.
0 commit comments