Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
246
rated 0 times [  246] [ 0]  / answers: 1 / hits: 127896  / 2 Years ago, sat, april 23, 2022, 8:23:28

I'm looking for a relatively painless way to launch a web server with document root in any folder I specify (or better yet, where I'm launching).



I often try out new things like JS frameworks or so in a new folder somewhere here:



/home/alexander/code/angularjs/


It would then be convenient to just go into this directory and type something like:



start-webserver-here 


so that a web server starts listening on port 80 and serving this directory, and I can try out whatever I'm working on.



I've installed XAMPP but it seems that it's basic apache with a document root I'd have to change, with root privileges even, along with granting permissions for every folder etc.



Is there an easier way?


More From » webserver

 Answers
2

Use



python2 -m SimpleHTTPServer 80


or



python3 -m http.server 80


to start a simple HTTP server.



Replace 80 with another number if you want it to listen on a different port. For ports < 1024 it needs to run with root privileges.


[#28386] Saturday, April 23, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
damomnning

Total Points: 422
Total Questions: 90
Total Answers: 106

Location: Mali
Member since Thu, Aug 13, 2020
4 Years ago
;