Http-server: Open browser with URL

Created on 8 Jan 2016  路  14Comments  路  Source: http-party/http-server

The -o option is really handy, but unless I'm missing something I can't ask for anything other than the root to be opened? It'd be handy if we could specific a relative path, e.g.

http-server -o /pages/index.html

Opens browser with http://localhost:8080/pages/index.html

Most helpful comment

I don't understand what the path part of -o [path] was supposed to do it if did not behave this way. At least _one_ of the four combinations above should be working. I find that (at least on my Linux installation) that it only launches the browser (at all) if I do not specify the path after -o at all.

Any progress on this issue? I'd love to specify a location and a file, or have the root location be implicit in the file, e.g.:
http-server site1 -o test1.html
or
http-server -o site1/test1.html

All 14 comments

This would be handy for me. Looks like pretty isolated changes.

I create a pull request #260 that allows for using both a relative path and still allow for using an absolute path in the same way as before.

I think its a none breaking change as paths starting with a '/' didnt do anything anyway and will still allow anybodies pre-existing scripts to run :) plus its handy to be able to use an absolute url at times as well.

The only stipulation is the relative path must start with a forward slash '/'.

Related to issue #197. PR #250 addresses this directly, and #234, #260 add work arounds. If they could be reviewed, that would be great :)

+1

I am unbale to open my index.html page using any of following commannd

-o index
-o index.html
-o 'index.html'
-o '/index.html'

Am i misisng on something..I npm installed http-server today itself so believe to have the above change. The browser for me still opens at localhost:8080

any updates on this issue?

Any news on this? Really seems like a useful feature to have!

I don't understand what the path part of -o [path] was supposed to do it if did not behave this way. At least _one_ of the four combinations above should be working. I find that (at least on my Linux installation) that it only launches the browser (at all) if I do not specify the path after -o at all.

Any progress on this issue? I'd love to specify a location and a file, or have the root location be implicit in the file, e.g.:
http-server site1 -o test1.html
or
http-server -o site1/test1.html

any news on this?=

Nothing opens for me at all with the -o flag.

There were a few PRs open to address this. It looks like https://github.com/indexzero/http-server/pull/250 was @thornjad chosen solution, and is waiting to be merged.

250 should be the one, I have a giant merge train in the works to get things moving.

I'm having the same problem. The -o option doesn't do anything on Ubuntu 18.04.2 LTS.

This awesome project is lacking a pulse and this was the feature I needed the most.

I wanted to set the public http static folder to ./ then launch to ./example/index.html.
But... the problem with -o is that it only launches to the root of the path.

http-server ./ -o

Workaround:

npm install live-server
live-server ./ --open='./example/'

Docs: https://www.npmjs.com/package/live-server

UPDATE:

So this feature was added in https://github.com/http-party/http-server/pull/250 but it's not in the latest release of the package.
BUG: https://github.com/http-party/http-server/pull/250#issuecomment-526567304

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thornjad picture thornjad  路  5Comments

laughinghan picture laughinghan  路  5Comments

jiyinyiyong picture jiyinyiyong  路  6Comments

gswebspace picture gswebspace  路  6Comments

dumptyd picture dumptyd  路  4Comments