You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**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 Actorto enable communication with the outside world through both UI and API.**
9
9
10
10
import Tabs from '@theme/Tabs';
11
11
import TabItem from '@theme/TabItem';
12
12
13
13
---
14
14
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:
16
20
17
21
- In the web application, on the Actor run details page as the **Container URL** field.
18
22
- In the API as the `containerUrl` property of the [Run object](/api/v2#/reference/actors/run-object/get-run).
19
23
- In the Actor run's container as the `ACTOR_WEB_SERVER_URL` environment variable.
20
24
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
22
30
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
24
36
25
37
<TabsgroupId="main">
26
38
<TabItemvalue="JavaScript"label="JavaScript">
27
39
40
+
Here's how to start a basic web server in your Actor using Express.js:
41
+
28
42
```js
29
43
// npm install express
30
44
import { Actor } from'apify';
@@ -52,6 +66,8 @@ await Actor.exit();
52
66
</TabItem>
53
67
<TabItemvalue="Python"label="Python">
54
68
69
+
Here's how to start a basic web server in your Actor using Flask:
0 commit comments