Skip to content

Commit 31b2f87

Browse files
authored
docs: improve container web server doc (#1122)
rework doc structure streamline the prose
1 parent df25bf6 commit 31b2f87

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

sources/platform/actors/development/programming_interface/container_web_server.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,40 @@ slug: /actors/development/programming-interface/container-web-server
55
sidebar_position: 7
66
---
77

8-
**Learn about how to run a web server inside your Actor, which enables you to communicate with the outer world via both UI and API.**
8+
**Learn about how to run a web server inside your Actor to enable communication with the outside world through both UI and API.**
99

1010
import Tabs from '@theme/Tabs';
1111
import TabItem from '@theme/TabItem';
1212

1313
---
1414

15-
Each Actor run is assigned a unique hard-to-guess URL (e.g. `kmdo7wpzlshygi.runs.apify.net`), which enables HTTP access to an optional web server running inside the Actor run's Docker container. The URL is available in the following places:
15+
Each Actor run is assigned a unique URL (e.g. `kmdo7wpzlshygi.runs.apify.net`) that allows HTTP access to an optional web server running inside the Actor's Docker container. This feature enhances your Actor's capabilities by enabling external communication.
16+
17+
## Access the container URL
18+
19+
You can find the container URL in three locations:
1620

1721
- In the web application, on the Actor run details page as the **Container URL** field.
1822
- In the API as the `containerUrl` property of the [Run object](/api/v2#/reference/actors/run-object/get-run).
1923
- In the Actor run's container as the `ACTOR_WEB_SERVER_URL` environment variable.
2024

21-
The web server running inside the container must listen at the port defined by the `ACTOR_WEB_SERVER_PORT` environment variable (typically 4321). If you want to use another port, simply define the `ACTOR_WEB_SERVER_PORT` environment variable with the desired port number in your Actor version configuration - see [Custom environment variables](./environment_variables.md) for details.
25+
## Set up the web server
26+
27+
The web server inside the container must listen on the port specified by the `ACTOR_WEB_SERVER_PORT` environment variable (typically: _4321_). To use a different port:
28+
29+
1. Go to your Actor version configuration
2230

23-
The following example demonstrates how to start a simple web server in your Actor:
31+
1. Define the `ACTOR_WEB_SERVER_PORT` environment variable with your desired port number.
32+
33+
Check out [Custom environment variables](./environment_variables.md) for more details.
34+
35+
## Example: Start a simple web server
2436

2537
<Tabs groupId="main">
2638
<TabItem value="JavaScript" label="JavaScript">
2739

40+
Here's how to start a basic web server in your Actor using Express.js:
41+
2842
```js
2943
// npm install express
3044
import { Actor } from 'apify';
@@ -52,6 +66,8 @@ await Actor.exit();
5266
</TabItem>
5367
<TabItem value="Python" label="Python">
5468

69+
Here's how to start a basic web server in your Actor using Flask:
70+
5571
```python
5672
# pip install flask
5773
import asyncio

0 commit comments

Comments
 (0)