Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change command for running examples in README #393

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,21 @@ As for the name: Sinatra + Warp = Scotty.

## Examples

Run /basic.hs to see Scotty in action:
Run `examples/basic.hs` to see Scotty in action (if you haven't, run `cabal update` first):

```bash
runghc examples/basic.hs
```
`Setting phasers to stun... (port 3000) (ctrl-c to quit)`

Or equivalently with [`stack`](https://docs.haskellstack.org/en/stable/):

```bash
stack exec -- scotty-basic
$ cabal run scotty-basic
pbrinkmeier marked this conversation as resolved.
Show resolved Hide resolved
Setting phasers to stun... (port 3000) (ctrl-c to quit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you keep the stack example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This command does not work when I test it in a recent fresh haskell Docker container. stack run [...] does, but only if a stack.yaml is present. If we keep this I'd suggest adding a stack.yaml file too so that it works out of the box, thoughts (see #390)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, adding a stack.yaml is not a good practice because it forces a fixed resolver on the users.

Indeed, I agree that the current stack example is not self-contained because it assumes a stack init && stack build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stack run -- scotty-basic works without stack build before but still requires a stack.yaml. I can try whether stack init && stack run ... works though. I guess for their own projects people can use whichever tool they want anyways.

```

Once the server is running you can interact with it with curl or a browser:
Once the server is running you can interact with it with `curl` or a browser:

```bash
curl localhost:3000
```
`foobar`

```bash
curl localhost:3000/foo_query?p=42
$ curl localhost:3000
foobar
$ curl localhost:3000/foo_query?p=42
<h1>42</h1>
```
`<h1>42</h1>`


Additionally, the `examples` directory shows a number of concrete use cases, e.g.

Expand All @@ -58,6 +48,8 @@ Additionally, the `examples` directory shows a number of concrete use cases, e.g
* [file upload](./examples/upload.hs)
* and more

You can run these using `cabal run scotty-exceptions`, `cabal run scotty-globalstate` etc.

## More Information

Tutorials and related projects can be found in the [Scotty wiki](https://github.com/scotty-web/scotty/wiki).
Expand Down
Loading