Comments (6)
Hello 👋🏻
if you've got your html files in KV (or r2) you can use this ~>
and how to use it check this ~>
hope that helps?
from worktop.
Correct if your HTML is external.
If you want to serve a local HTML file, you can use the worktop.build
package and just import the HTML file directly
import { reply } from "worktop/response";
import HOME from "./index.html";
API.add("GET", "/", (req, context) => {
return reply(200, HOME, {
"content-type": "text/html; charset=utf-8"
});
});
then in your type declarations somewhere you do this:
declare module "*.html" {
const html: string;
export default html;
}
Hope that helps!
from worktop.
@lukeed but how about serving dynamic content that expects a certain extension? E.g.:
/:fileName[.html]
?
from worktop.
I don’t understand the question; it’s too vague. You could be asking two or three different things. Wdym?
from worktop.
I'd like to use parameterised routing, but only have it match a specific pattern, that is, that the parameter should end on ".html"
from worktop.
You can do that ::
API.add("GET", "/:file.html", async (req, context) => {
context.params.file //=> “foobar”
});
// GET /foobar.html
from worktop.
Related Issues (20)
- Using Worktop in a Pages website HOT 3
- Use Sveltekit and worktop together? HOT 2
- How to set multiple cookies? HOT 2
- Worktop Middlewares Example HOT 4
- Durable Objects example HOT 2
- The example of timing requests might be misleading HOT 1
- Using official Cloudflare types HOT 4
- Can I use Worktop with Fastly Compute@Edge? HOT 1
- Is it going to be official by cloudflare?
- Cache API and KV: Concerns/Questions/Usage HOT 1
- How to access `.env` with Wrangler 2 HOT 2
- Provide a "test" module HOT 4
- How to use with cron / scheduled event ? HOT 2
- Is `worktop@next` safe to use in production? HOT 2
- Add generic typing for Router.add handler
- The uploaded script has no registered event handlers. [API code: 10068] HOT 1
- Add sub-routers HOT 2
- Node 16+ ESM TypeScript error HOT 1
- `isCacheable` allowed cache by default if the `cache-control` header is empty may leading to a security flaw in ssg content HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from worktop.