# Example

## Define an API

```python
# main.py

print("hello world")
```

## Create a `Dockerfile`

```
FROM python:3.8-slim

COPY main.py /

CMD exec python main.py
```

## Build an image

```bash
docker build . -t hello-world
```

## Run a container locally

```bash
docker run -it --rm hello-world
```

## Login to ECR

```bash
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com
```

## Create a repository

```bash
aws ecr create-repository --repository-name hello-world
```

## Tag the image

```bash
docker tag hello-world <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/hello-world
```

## Push the image

```bash
docker push <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/hello-world
```

## Configure a Cortex deployment

```yaml
# cortex.yaml

- name: hello-world
  kind: TaskAPI
  pod:
    containers:
    - name: api
      image: <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/hello-world
      command: ["python", "main.py"]
```

## Create a Cortex deployment

```bash
cortex deploy
```

## Get the API endpoint

```bash
cortex get hello-world
```

## Make a request

```bash
curl -X POST -H "Content-Type: application/json" -d '{}' http://***.amazonaws.com/hello-world
```

## View the logs

```bash
cortex logs hello-world <JOB_ID>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortexlabs.com/0.38/workloads/task/example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
