Skip to content

Comments

serve cmd#358

Merged
tomer-stripe merged 2 commits intomasterfrom
tomer/serve-cmd
Jan 29, 2020
Merged

serve cmd#358
tomer-stripe merged 2 commits intomasterfrom
tomer/serve-cmd

Conversation

@tomer-stripe
Copy link
Collaborator

@tomer-stripe tomer-stripe commented Jan 28, 2020

Reviewers

r? @ob-stripe @adreyfus-stripe
cc @stripe/dev-platform @suz-stripe @brandur-stripe

Summary

This adds a simple command to serve static files from the CLI. We'd like this for samples since a number of them have an index.html file and we've been suggested folks use the Python simple server, which may require installing the entire Python ecosystem.

The command is stripe serve (or stripe srv) which takes an optional argument that is a path to a directory. If not path is given, it serve the local folder: '.'.

The command has some basic logging available to it when requests are made:

➜ stripe-dev serve
Starting stripe server at address http://localhost:4242
::1 - - [28/Jan/2020:10:33:36 -0800] "GET / HTTP/1.1" 304 0
::1 - - [28/Jan/2020:10:33:41 -0800] "GET /.editorconfig HTTP/1.1" 200 233
^Csignal: interrupt

If an index.html file exists in the folder, the CLI will automatically render that. If not, it'll display a list of files in that specific directory.

The command itself will continue running (and block) until the user kills it with ctrl+c.

@tomer-stripe tomer-stripe changed the title Tomer/serve cmd serve cmd Jan 28, 2020
@suz-stripe
Copy link
Contributor

I think this is a nice convenience and helps keep our documentation more concise with fewer non-Stripe related rabbit holes 💯

Copy link
Contributor

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I wonder if there's any way we can make the command more "Stripe specific", e.g. by looking for files specific to our samples and displaying some relevant information? Just food for thought for future improvements.

@tomer-stripe
Copy link
Collaborator Author

@ob-stripe that's a good idea. I wonder if we could leverage the cli setup files we made for samples to give users additional instructions 🤔

@adreyfus-stripe what do you think?

@adreyfus-stripe
Copy link
Collaborator

I like this as a first pass! Ultimately we could extend to add more serve config via .cli.json

@tomer-stripe tomer-stripe merged commit f3743f2 into master Jan 29, 2020
@tomer-stripe tomer-stripe deleted the tomer/serve-cmd branch January 29, 2020 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants