0

Since the absolute path of HTTP and the absolute path of linux files are essentially different, I want to find a software to act as a temporary HTTP server to assist me in web development.

Suppose the name of this software is server. I hope that when I enter a command, it will start immediately and treat all files in the current directory as static resources.

$ server --port 8080

The port opened by the software is 8080, and there is a demo.txt file in the current directory.

After that, I can ask the file through http://localhost:8080/demo.txt in the browser.

Is there such a linux software package?

I know that nginx can fulfill my test requirements, but for this kind of not particularly complicated function, configuring ningx is not very cost-effective.

2 Answers 2

2

See the post Simple command line HTTP server.

Among the suggested products are SimpleHTTPServer and a whole lot of others in the
Big list of http static server one-liners.

1

Since nowadays every Linux distro is shipped with python, you can use it to start a HTTP server that will list and enable you to download the files present in the current directory.

Just run: python3 -m http.server 8080

1
  • Just note that PHP can do the same (e.g. php -S localhost:8080).
    – Izzy
    Jan 10 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.