Skip to content

Commit 2f3caa4

Browse files
authored
Update examples (#2234)
1 parent 37eba1d commit 2f3caa4

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

docs/workloads/async/example.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
# main.py
77

88
from fastapi import FastAPI
9+
from pydantic import BaseModel
910

1011
app = FastAPI()
1112

13+
class Data(BaseModel):
14+
msg: str
15+
1216
@app.post("/")
13-
def hello_world():
14-
return {"msg": "hello world"}
17+
def handle_async(data: Data):
18+
return data
1519
```
1620

1721
### Create a `Dockerfile`
@@ -28,19 +32,19 @@ CMD uvicorn --host 0.0.0.0 --port 8080 main:app
2832
### Build an image
2933

3034
```bash
31-
docker build . --tag hello-world
35+
docker build . -t hello-world
3236
```
3337

3438
### Run a container locally
3539

3640
```bash
37-
docker run --port 8080:8080 hello-world
41+
docker run -p 8080:8080 hello-world
3842
```
3943

4044
### Make a request
4145

4246
```bash
43-
curl --request POST --header "Content-Type: application/json" localhost:8080
47+
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' localhost:8080
4448
```
4549

4650
### Login to ECR
@@ -101,7 +105,7 @@ cortex get hello-world
101105
### Make a request
102106

103107
```bash
104-
curl --request POST --header "Content-Type: application/json" http://***.amazonaws.com/hello-world
108+
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' http://***.amazonaws.com/hello-world
105109
```
106110

107111
### Get the response

docs/workloads/batch/example.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def on_job_complete():
2525
FROM python:3.8-slim
2626

2727
RUN pip install --no-cache-dir fastapi uvicorn
28+
2829
COPY main.py /
2930

3031
CMD uvicorn --host 0.0.0.0 --port 8080 main:app
@@ -33,19 +34,19 @@ CMD uvicorn --host 0.0.0.0 --port 8080 main:app
3334
### Build an image
3435

3536
```bash
36-
docker build . --tag hello-world
37+
docker build . -t hello-world
3738
```
3839

3940
### Run a container locally
4041

4142
```bash
42-
docker run --port 8080:8080 hello-world
43+
docker run -p 8080:8080 hello-world
4344
```
4445

4546
### Make a request
4647

4748
```bash
48-
curl --request POST --header "Content-Type: application/json" --data '[1,2,3,4]' localhost:8080
49+
curl -X POST -H "Content-Type: application/json" -d '[1,2,3,4]' localhost:8080
4950
```
5051

5152
### Login to ECR
@@ -101,7 +102,7 @@ cortex get hello-world
101102
### Make a request
102103

103104
```bash
104-
curl --request POST --header "Content-Type: application/json" --data '{"workers": 2, "item_list": {"items": [1,2,3,4], "batch_size": 2}}' http://***.amazonaws.com/hello-world
105+
curl -X POST -H "Content-Type: application/json" -d '{"workers": 2, "item_list": {"items": [1,2,3,4], "batch_size": 2}}' http://***.amazonaws.com/hello-world
105106
```
106107

107108
### View the logs

docs/workloads/realtime/example.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
# main.py
77

88
from fastapi import FastAPI
9+
from pydantic import BaseModel
910

1011
app = FastAPI()
1112

12-
@app.get("/")
13-
def hello_world():
14-
return {"msg": "hello world"}
13+
class Data(BaseModel):
14+
msg: str
15+
16+
@app.post("/")
17+
def handle_post(data: Data):
18+
return data
1519
```
1620

1721
### Create a `Dockerfile`
@@ -20,6 +24,7 @@ def hello_world():
2024
FROM python:3.8-slim
2125

2226
RUN pip install --no-cache-dir fastapi uvicorn
27+
2328
COPY main.py /
2429

2530
CMD uvicorn --host 0.0.0.0 --port 8080 main:app
@@ -28,19 +33,19 @@ CMD uvicorn --host 0.0.0.0 --port 8080 main:app
2833
### Build an image
2934

3035
```bash
31-
docker build . --tag hello-world
36+
docker build . -t hello-world
3237
```
3338

3439
### Run a container locally
3540

3641
```bash
37-
docker run --port 8080:8080 hello-world
42+
docker run -p 8080:8080 hello-world
3843
```
3944

4045
### Make a request
4146

4247
```bash
43-
curl --request POST localhost:8080
48+
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' localhost:8080
4449
```
4550

4651
### Login to ECR
@@ -101,5 +106,5 @@ cortex get hello-world
101106
### Make a request
102107

103108
```bash
104-
curl --request POST http://***.amazonaws.com/hello-world
109+
curl -X POST -H "Content-Type: application/json" -d '{"msg": "hello world"}' http://***.amazonaws.com/hello-world
105110
```

docs/workloads/task/example.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CMD exec python main.py
2121
### Build an image
2222

2323
```bash
24-
docker build . --tag hello-world
24+
docker build . -t hello-world
2525
```
2626

2727
### Run a container locally
@@ -83,7 +83,7 @@ cortex get hello-world
8383
### Make a request
8484

8585
```bash
86-
curl --request POST --header "Content-Type: application/json" --data '{}' http://***.amazonaws.com/hello-world
86+
curl -X POST -H "Content-Type: application/json" -d '{}' http://***.amazonaws.com/hello-world
8787
```
8888

8989
### View the logs

0 commit comments

Comments
 (0)