How to run a html file on localhost (any port)
You can use caddy
Install: brew install caddy
To serve static files from the current working directory, run:
caddy file-server --browse --listen :2015
Caddy's default port is 2015, so open your browser to http://localhost:2015.
IIRC macOS comes with PHP preinstalled, and PHP has built-in web-server which should be enough for serving static content.
So, open Terminal.app and then:
cd your/project/dir
php -S localhost:8080
After than you can navigate to http://localhost:8080/ and see your site in the browser (given you have index.html
in your project, otherwise there will be "Not Found" message).
There are more advanced and/or less terminal-oriented ways, of course, but since you already tinkering with python and node, another terminal command should not be a problem.
BTW, you might want to look at that terminal window from time to time, as it outputs nice log of what things were requested from server. Good if you want to check for invalid references, 404 errors, etc. Here is a sample output:
$ php -S localhost:8080
PHP 7.3.6 Development Server started at Sat Jun 22 20:00:28 2019
Listening on http://localhost:8080
Document root is /private/tmp/test
Press Ctrl-C to quit.
[Sat Jun 22 20:00:32 2019] [::1]:51640 [200]: /
[Sat Jun 22 20:00:32 2019] [::1]:51641 [200]: /style.css
[Sat Jun 22 20:02:35 2019] [::1]:51670 [404]: /oops.html - No such file or directory
As you can see, root folder (/
, which was translated to index.html
in my case) and a stylesheet (style.css
) were requested and successfully delivered (code is 200
). But non-existent file oops.html
resulted in error (code is 404
).