Skip to content

Add an embedded web server #982

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

Closed

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Jun 3, 2022

Every time I want to write a blog post, I have to go look up what way to invoke python http or whatever to get a locally visible preview of my work.

Today I decided to try something different.

pnkfelix added 5 commits June 3, 2022 11:24
(I'm not yet trying to do any fancy monitoring of changes to the files and
subsequent regeneration. This is all meant to be very bare bones.)

To accomplish this I had to make the main crate callable from other crates,
which in turn required some small changes to how it pulls in its own child
modules, since `main` can no longer assume it is the crate root.
@Mark-Simulacrum
Copy link
Member

I think we're 90-95% done with migrating to relative urls (thanks to @m-ou-se), which should make file:/// urls work out of the box, I'd hope - I'd rather avoid the extra complexity here if we can, particularly in terms of compile times in CI.

Would file:/// URLs work for you, @pnkfelix?

@m-ou-se
Copy link
Member

m-ou-se commented Jun 3, 2022

See #967 and #980 and #981

@pietroalbini
Copy link
Member

Yeah, the worry I have with this is the compile time increase, as we're now pulling tokio, hyper and other heavyweight dependencies.

I'm not opposed to including the web server, but it must not cause compile time increases. A way to do that would be to setup the repo as a workspace and add the dependencies only to the server binary crate.

@pnkfelix
Copy link
Member Author

pnkfelix commented Jun 4, 2022

The file approach won’t work for me; I do my development on a distinct box from where I do the preview

I’ll look into the variant that Pietro proposed.

@pnkfelix pnkfelix closed this Jun 4, 2022
@bjorn3
Copy link
Member

bjorn3 commented Jun 4, 2022

Maybe use tiny_http? It is a light weight http server with only a few dependencies. Including dependencies (part of which are probably already used here) it takes 10s to compile in debug mode, 15s in release mode and 7s with cg_clif.

@Mark-Simulacrum
Copy link
Member

I have to go look up what way to invoke python http or whatever to get a locally visible preview of my work.

FWIW, if this is the problem, I have no objections to us printing "run python3 -m http.server output/ or open file:///..." or some similar message after running the blog, that seems like an easy change to make and a good improvement regardless.

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.

6 participants