Search code examples
htmlexpressuploadwebserverftp-server

Setup a web server with uploading index.html to a ftp server


So i started learning about express and searched some tutorial. And in one i saw that the guy uploaded his index.html to a ftp server and he refreshed the page the ftp server index gone and the web server was up.

I started searching to how to make this and i found nothing.

Somebody know how to make this type of ftp server? (upload index.html to ftp server and then it will "became" a web server)

(sorry for bad english)


Solution

  • You've misunderstood what you've seen.

    A traditional HTTP server will serve up any files in a given directory. (The DocumentRoot in Apache HTTPD terms).

    An FTP server lets you copy files to a directory on a computer on a network.

    What you saw was a computer which was already running an HTTP server and an FTP server and a file was just uploaded, using FTP, to the directory that the HTTP server treated as the DocumentRoot.


    You could use Node.js to write a piece of software that includes both an HTTP server capable of serving static files (Express + the static middleware would make that easy) and an FTP server (e.g. with ftp-srv).

    However, if that's all you want, you would probably be better off installing existing, mature HTTP and FTP servers instead of writing your own.