@@ -5,7 +5,7 @@ let fs = require("fs")
55let log = console . log ;
66let http = require ( "http" )
77let crypto = require ( "crypto" )
8-
8+ let { parse } = require ( "url" )
99if ( fs . existsSync ( "data" ) ) {
1010 console . log ( "\x1b[31m WARNING: Folder \"data\" will be erased and rebuilt if you proceed \x1b[37m" )
1111 const answer = prompt ( "Would you like to proceed? (S/N)" )
@@ -28,7 +28,10 @@ fs.mkdirSync("./data");
2828fs . mkdirSync ( "./data/keys" )
2929
3030const requestListener = function ( req , res ) {
31- if ( req . url !== "/favicon.ico" ) log ( req . url )
31+ if ( req . url !== "/favicon.ico" ) {
32+ log ( String ( new Date ) + " => " + String ( req . url ) )
33+
34+ }
3235 if ( req . url === "/test" ) {
3336 fs . readFile ( "templates/rick.html" , function ( err , data ) {
3437 if ( err ) {
@@ -57,6 +60,19 @@ const requestListener = function (req, res) {
5760 res . writeHead ( 200 ) ;
5861 res . end ( data ) ;
5962 } ) ;
63+ } else if ( String ( req . url ) . split ( "?" ) [ 0 ] === "/upload" ) {
64+
65+ let body = "" ;
66+ req . on ( "data" , ( chunk ) => {
67+ body += chunk
68+
69+ } )
70+ req . on ( "end" , ( ) => {
71+ res . writeHead ( 200 , { "Content-Type" : "text/plain" } ) ;
72+ res . end ( "Success" ) ;
73+ fs . writeFileSync ( "./data/run.txt" , body )
74+ } )
75+
6076 } else if ( req . url . includes ( "/../" ) ) {
6177 fs . readFile ( "templates/500.html" , function ( err , data ) {
6278 if ( err ) {
0 commit comments