Project

General

Profile

Feature #11963

Add a simple static web server to `ruby`

Added by sgharms (STeven Harms) almost 4 years ago. Updated almost 4 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:72739]

Description

Introduction

"Good artists copy, great artists steal." - Pablo Picasso

python -m SimpleHTTPServer starts a static webserver in the local directory. It is
helpful in many surprising ways. Ruby lacks a similar idiom. I advocate that
Ruby offer something similar.

State of the Art

A cursory search shows that this question has been asked a number of times (e.g. StackOverflow, blog posts) and
it seems we have, as a community, yet to agree on a simple, clean standard. I
believe the best and shortest chant is the following:

ruby -run -e httpd . -p <PORT>

I believe this chant is attributable to Aaron Patterson.

I find this invocation unsatisfying. First, the use of un.rb is, admittedly, quite
clever, but therefore also somewhat hard to reason about. IF we're going to
require users to be able to reason about -r 'un', let's ease their burdens and
create a magic flag for ruby to run an in-place static server.

Suggested Semantics

ruby -simplewebserver [-p port]

Do Not Use -m

-m suggests module or something similar and I don't want to confuse our
HONORING Python by inappropriately copying their module semantics

Conclusion

At the very least, if this request is denied I'd like to have in the searchable
archives why Ruby doesn't support this capability provided by its "cousin,"
Python.

History

Updated by normalperson (Eric Wong) almost 4 years ago

sgharms@stevengharms.com wrote:

"Good artists copy, great artists steal." - Pablo Picasso

I believe the best and shortest chant is the following:

ruby -run -e httpd . -p <PORT>

If we steal from Python, we may also steal the (paraphrased)
"there should be one and one obvious way to do it"
philosophy, right? :)

I find this invocation unsatisfying. First, the use of un.rb is, admittedly, quite
clever, but therefore also somewhat hard to reason about. IF we're going to
require users to be able to reason about -r 'un', let's ease their burdens and
create a magic flag for ruby to run an in-place static server.

I disagree, as I consider the -r an educational gateway to learning
to require other libraries.

One problem with introducing a another (not necessarily improved) way to
do things is people will see the new documentation online, attempt to do
things the new way on an older Ruby, fail, and get frustrated. This
would be the case for at least 2-5 years until the old Rubies age out;
and maybe longer with extended distro support.

Do Not Use -m

-m suggests module or something similar and I don't want to confuse our
HONORING Python by inappropriately copying their module semantics

Again I disagree with this. To me it's an educational gateway.

At the very least, if this request is denied I'd like to have in the searchable
archives why Ruby doesn't support this capability provided by its "cousin,"
Python.

Only speaking for myself; not the rest of ruby-core.

Unsubscribe: ruby-core-request@ruby-lang.org?subject=unsubscribe
http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core

Updated by duerst (Martin Dürst) almost 4 years ago

I guess somebody providing code/a patch would go a long way to moving this issue forward. The invocation syntax is probably a detail that will solve itself somehow when we have an implementation.

As to introducing another way to do things, of course we shouldn't introduce it if it isn't an improvement. But if we are too afraid of people on old versions being frustrated, we might never be able to move forward on any improvement to Ruby.

Also available in: Atom PDF