···8899Let's say I want to self-host my own drawing app.
10101111-```bash
1212-# the app subdomain will be draw.<your-domain>
1111+First, I'll create a folder for my app:
1212+1313+```ts
1314mkdir -p ~/smallweb/draw
1515+```
14161515-# Smallweb apps can be contained in a single file
1616-cat <<EOF > ~/smallweb/draw/main.ts
1717+Then, I'll create a `main.ts` file in that folder:
1818+1919+```ts
2020+// ~/smallweb/draw/main.ts
1721import { Excalidraw } from "jsr:@smallweb/excalidraw@0.9.1";
18221923const excalidraw = new Excalidraw({
···2125});
22262327export default excalidraw;
2424-EOF
2528```
26292730And voila! No need to run a single command, your website is already available at `https://draw.<your-domain>`! And each time the drawing is modified, it get automatically persited to `~/smallweb/draw/data/drawing.json`.
···43464447export default {
4548 fetch: (request: Request) => {
4646- return new Response("Example server!");
4949+ return new Response("Handling request!");
4750 },
4848- run: () => {
4949- console.log("Example cli!");
5050- }
5151+ run: (_args: string[]) => {
5252+ console.log("Running command!");
5353+ },
5454+ email: (_msg: ReadableStream) => {
5555+ console.log("Received email!");
5656+ },
5157}
5258```
5359···55615662- the `fetch` function by send a request to `https://example.<your-domain>`
5763- the `run` function by running `smallweb run example` or `ssh example@<your-domain>`
6464+- the `email` function by sending an email to `example!<your-domain>`
58655966Of course, it is super easy to hook these functions to a web framweork like [hono](https://hono.dev) or a cli framework like [commander](https://www.npmjs.com/package/commander).
6067