Skip to content
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

docs: add "Initialize a web server" section #723

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
```
Loading