Skip to content

Commit

Permalink
docs: add "Initialize a web server" section (denoland#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua authored Aug 20, 2024
1 parent 48dbb3a commit 23dd886
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions runtime/manual/tools/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,50 @@ Inside `deno.json` you'll see that the entries for `name`, `exports` and
}
}
```

## Initialize a web server

Running `deno init --serve` bootstraps a web server that works with
[`deno serve`](./serve).

```sh
$ deno init --serve
✅ Project initialized

Run these commands to get started

# Run the server
deno serve -R main.ts

# Run the server and watch for file changes
deno task dev

# Run the tests
deno -R test
```

Your [`deno.json`](../getting_started/configuration_file) file will look like
this:

```json
{
"tasks": {
"dev": "deno serve --watch -R main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/http": "jsr:@std/http@1"
}
}
```

Now, you can start your web server, which
[watches for changes](../getting_started/command_line_interface#watch-mode), by
running `deno task dev`.

```sh
$ deno task dev
Task dev deno serve --watch -R main.ts
Watcher Process started.
deno serve: Listening on http://0.0.0.0:8000/
```

0 comments on commit 23dd886

Please sign in to comment.