Serve a directory of static files
See original GitHub issueHi, thanks for doing this @sholladay - is there a way to serve a directory of static files at a particular path with the correct response type set automatically?
The use case is to serve the web UI- e.g. the production build of a create-react-app project
In Hapi, I can do this with @hapi/inert and the directory handler it gives.
server.route({
method: "GET",
path: "/app/{path*}",
handler: {
directory: {
path: Path.join(__dirname, "../../client/build/"),
listing: false,
index: true
}
}
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
What exactly does 'serving static files' mean? - Stack Overflow
Static files are typically files such as scripts, CSS files, images, etc... that aren't server-generated, but must be sent to the browser when ......
Read more >Many Options to Run a Local Static Server | by Jair Reina
You should first enter to your “project” folder in the command line doing ... You can of course use it just to serve...
Read more >How to manage static files (e.g. images, JavaScript, CSS)
Store your static files in a folder called static in your app. For example my_app/static/my_app/example.jpg . Serving the files.
Read more >ExpressJS - Serving static files - Tutorialspoint
ExpressJS - Serving static files, Static files are files that clients download as they are from the server. Create a new directory, public....
Read more >Serving Static Resources in Node.js - TutorialsTeacher
It is easy to serve static files using built-in middleware in Express.js called express.static. Using express.static() method, you can server static resources ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Deno (via TypeScript) compiles the JSX syntax to
React.createElement()calls, so long as a.jsxor.tsxfile extension is used. However, Deno does not provide an implementation of React, so we need toimportReact anywhere that JSX is used. Pogo is responsible for rendering those React calls to static HTML markup viaReactDOMServer. Or you can render them yourself and return the markup as a string, Pogo will still treat it as HTML.I hope that clears things up! We could probably use an FAQ section with that in it. I also just noticed that the README mentions the Pika CDN, which I had to stop using due to some bugs. That needs to be updated.
This feature should be easier to implement now because of the new router (see #29).
Previously, you would’ve had to read the filesystem and map all of the desired file names to a list of paths and then construct a list of routes based on that, which would be annoying.
Now, we have support for wildcard paths, such as
/{foo*}, which will match any request that starts with/. Or/bar/{foo*}, which will match any request that starts with/bar/. You’ll probably want to use that in any route that serves a directory so that it can look up arbitrary file names from within the handler.