:title
1. Getting started

:content
Capy programs run as Bearer units. A source file uses the `.capy` suffix. Bearer compiles the file when a request first uses it.

## Your first page

Create `site/hello.capy`:

:example capy render
function RENDER()
{
	print("Hello, Capy!\n")
}

:output
Hello, Capy!

:content
`RENDER` is the entry point for a web request. `print` adds text to the response. The `\n` escape adds a newline.

Request the page through Bearer's default local HTTP socket:

```text
curl --unix-socket /run/bearer/http.sock http://localhost/hello.capy
```

The command prints the response body. Bearer logs compiler and runtime errors.

## Add a value

A local declaration uses `:=`. Capy infers the type from the value:

:example capy render
function RENDER()
{
	var name := "Ada"
	print("Hello, ", name, "!\n")
}

:content

`print` accepts several arguments and writes them in order.

## Write HTML

An HTML literal produces a string with escaped dynamic text:

:example capy render
function RENDER()
{
	var name := "Ada"
	print(<><h1>Hello, <?= name ?>!</h1></>)
}

:content

`print` writes the string to the response. An HTML literal alone does not produce output. The Strings and HTML chapter explains escaping.

## If it does not run

Confirm that `bearer.service` is active. The source file must be below the configured site directory. The CLI helper must use the configured local socket.

## Make the first change small

Change one value and request the page again. For example, change `Ada` to your name. This proves that Bearer sees the file you edited.

Then add one standard-library call, such as `request.out.headers["Content-Type"] = "text/plain; charset=utf-8"`. Small changes make compiler errors easier to isolate.

Continue with basic source syntax before you add request data or application APIs.

:see-group
guides

:see
handler/render
handler/cli
print
capy-02-source-structure-and-syntax
capy-06-strings-and-markup
