Skip to content

Add explanation how to run local web server#119

Merged
cdepillabout merged 1 commit intowebfrom
web-explanation
Oct 1, 2022
Merged

Add explanation how to run local web server#119
cdepillabout merged 1 commit intowebfrom
web-explanation

Conversation

@cdepillabout
Copy link
Copy Markdown
Owner

This PR is for #116. It just adds a simple explanation of how to run a local web server.

@cdepillabout cdepillabout mentioned this pull request Sep 28, 2022
Running this executable with `cabal run web` will start a web server listening on
`0.0.0.0:8000`. You should be able to see the web page by opening
<http://localhost:8000> in a web browser. _Note_ that you will need to run
`cabal run web` within this current directory.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah, this is presumably because runApp refers to style.css by relative path. There should be some way around this. Maybe using file-embed?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yeah, we could use something like file-embed to do this. I figured just explaining it in the documentation was the easiest thing to do here, but we could always improve it in the future it ends up being annoying.

runApp :: JSM () -> IO ()
runApp f =
runApp f = do
putStrLn "Web server running on 0.0.0.0:8000..."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Out of interest, why 0.0.0.0 instead of localhost?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

It appears that by default warp actually does listen on all interfaces (0.0.0.0), and not just localhost. So I felt this message was "more correct", although I guess some developers might not know that 0.0.0.0 means they can connect by accessing http://127.0.0.1:8000.

@cdepillabout cdepillabout merged commit 932887a into web Oct 1, 2022
@cdepillabout cdepillabout deleted the web-explanation branch October 1, 2022 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants