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
Copy file name to clipboardExpand all lines: docs/guide/runtimes/http.md
+26-19Lines changed: 26 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# HTTP Bridge Guide
2
2
3
-
`HttpBridge` connects to a Python server over HTTP. Use it when Python must run separately — including Deno Deploy, serverless environments, or distributed architectures.
3
+
`HttpBridge` connects to a Python server over HTTP. Use it when Python must run
4
+
separately — including Deno Deploy, serverless environments, or distributed
5
+
architectures.
4
6
5
7
## When to Use HttpBridge
6
8
@@ -21,29 +23,34 @@ pip install tywrap-ir
21
23
import { HttpBridge } from'tywrap/http';
22
24
import { setRuntimeBridge } from'tywrap/runtime';
23
25
24
-
setRuntimeBridge(newHttpBridge({
25
-
baseURL: 'http://localhost:8080',
26
-
timeoutMs: 30000,
27
-
headers: {
28
-
'Authorization': 'Bearer your-token',
29
-
},
30
-
}));
26
+
setRuntimeBridge(
27
+
newHttpBridge({
28
+
baseURL: 'http://localhost:8080',
29
+
timeoutMs: 30000,
30
+
headers: {
31
+
Authorization: 'Bearer your-token',
32
+
},
33
+
})
34
+
);
31
35
```
32
36
33
37
## Options
34
38
35
-
| Option | Required | Default | Description |
36
-
|--------|----------|---------|-------------|
37
-
|`baseURL`| Yes | — | Base URL of the Python bridge server |
38
-
|`headers`| No |`{}`| Additional HTTP headers (auth, CORS, etc.) |
39
-
|`timeoutMs`| No |`30000`| Request timeout in milliseconds |
|`baseURL`| Yes | — | Base URL of the Python bridge server|
42
+
|`headers`| No |`{}`| Additional HTTP headers (auth, CORS, etc.) |
43
+
|`timeoutMs`| No |`30000`| Request timeout in milliseconds|
44
+
|`codec`| No | Arrow | Codec options|
41
45
42
46
## Running the Python Server
43
47
44
-
`HttpBridge` expects a server that accepts POST requests with JSON/Arrow payloads. You must implement or deploy a compatible server endpoint. The protocol is stateless — each call is an independent POST request.
48
+
`HttpBridge` expects a server that accepts POST requests with JSON/Arrow
49
+
payloads. You must implement or deploy a compatible server endpoint. The
50
+
protocol is stateless — each call is an independent POST request.
45
51
46
-
> **Note:** A built-in server command is not yet available. See the [API reference](/reference/api/) for the expected request/response format.
52
+
> **Note:** tywrap does not ship an HTTP server. See the
53
+
> [API reference](/reference/api/) for the expected request/response format.
Copy file name to clipboardExpand all lines: docs/public/llms-full.txt
+34-27Lines changed: 34 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -2031,7 +2031,9 @@ Run `tywrap generate` during your build and load Pyodide at runtime (CDN or self
2031
2031
<!-- Source: docs/guide/runtimes/http.md -->
2032
2032
# HTTP Bridge Guide
2033
2033
2034
-
`HttpBridge` connects to a Python server over HTTP. Use it when Python must run separately — including Deno Deploy, serverless environments, or distributed architectures.
2034
+
`HttpBridge` connects to a Python server over HTTP. Use it when Python must run
2035
+
separately — including Deno Deploy, serverless environments, or distributed
2036
+
architectures.
2035
2037
2036
2038
## When to Use HttpBridge
2037
2039
@@ -2052,29 +2054,34 @@ pip install tywrap-ir
2052
2054
import { HttpBridge } from 'tywrap/http';
2053
2055
import { setRuntimeBridge } from 'tywrap/runtime';
2054
2056
2055
-
setRuntimeBridge(new HttpBridge({
2056
-
baseURL: 'http://localhost:8080',
2057
-
timeoutMs: 30000,
2058
-
headers: {
2059
-
'Authorization': 'Bearer your-token',
2060
-
},
2061
-
}));
2057
+
setRuntimeBridge(
2058
+
new HttpBridge({
2059
+
baseURL: 'http://localhost:8080',
2060
+
timeoutMs: 30000,
2061
+
headers: {
2062
+
Authorization: 'Bearer your-token',
2063
+
},
2064
+
})
2065
+
);
2062
2066
```
2063
2067
2064
2068
## Options
2065
2069
2066
-
| Option | Required | Default | Description |
2067
-
|--------|----------|---------|-------------|
2068
-
| `baseURL` | Yes | — | Base URL of the Python bridge server |
| `timeoutMs` | No | `30000` | Request timeout in milliseconds |
2075
+
| `codec` | No | Arrow | Codec options |
2072
2076
2073
2077
## Running the Python Server
2074
2078
2075
-
`HttpBridge` expects a server that accepts POST requests with JSON/Arrow payloads. You must implement or deploy a compatible server endpoint. The protocol is stateless — each call is an independent POST request.
2079
+
`HttpBridge` expects a server that accepts POST requests with JSON/Arrow
2080
+
payloads. You must implement or deploy a compatible server endpoint. The
2081
+
protocol is stateless — each call is an independent POST request.
2076
2082
2077
-
> **Note:** A built-in server command is not yet available. See the [API reference](https://bbopen.github.io/tywrap/reference/api/) for the expected request/response format.
2083
+
> **Note:** tywrap does not ship an HTTP server. See the
2084
+
> [API reference](https://bbopen.github.io/tywrap/reference/api/) for the expected request/response format.
| `TYWRAP_CODEC_FALLBACK` | Python bridge | unset | Set to `json` to allow JSON fallback when Arrow encoding is unavailable |
2384
-
| `TYWRAP_CODEC_MAX_BYTES` | Python bridge | unset | Reject response payloads larger than this byte count (applied post-reassembly) |
2385
-
| `TYWRAP_REQUEST_MAX_BYTES` | Python bridge | unset | Reject request payloads larger than this byte count (applied post-reassembly) |
2386
-
| `TYWRAP_TORCH_ALLOW_COPY` | Python bridge | off | Allow GPU-to-CPU or contiguous-copy conversion when serializing `torch.Tensor` |
2387
-
| `TYWRAP_ALLOWED_MODULES` | Python bridge | unset | Comma- and/or whitespace-separated import allowlist; blank is unset, while a non-empty value permits only named modules plus bridge-required stdlib modules |
2388
-
| `TYWRAP_ALLOW_PRIVATE_ATTRS` | Python bridge | off | Set to `1`, `true`, or `yes` to allow underscore-prefixed attribute access; otherwise it is blocked |
| `TYWRAP_CODEC_FALLBACK` | Python bridge | unset | Set to `json` to allow JSON fallback when Arrow encoding is unavailable |
2391
+
| `TYWRAP_CODEC_MAX_BYTES` | Python bridge | unset | Reject response payloads larger than this byte count (applied post-reassembly) |
2392
+
| `TYWRAP_REQUEST_MAX_BYTES` | Python bridge | unset | Reject request payloads larger than this byte count (applied post-reassembly) |
2393
+
| `TYWRAP_TORCH_ALLOW_COPY` | Python bridge | off | Allow GPU-to-CPU or contiguous-copy conversion when serializing `torch.Tensor` |
2394
+
| `TYWRAP_ALLOWED_MODULES` | Python bridge | unset | Comma- and/or whitespace-separated import allowlist; blank is unset, while a non-empty value permits only named modules plus bridge-required stdlib modules. See [SECURITY.md](https://github.com/bbopen/tywrap/blob/main/SECURITY.md). |
2395
+
| `TYWRAP_ALLOW_PRIVATE_ATTRS` | Python bridge | off | Set to `1`, `true`, or `yes` to allow underscore-prefixed attribute access; otherwise it is blocked |
|`TYWRAP_CODEC_FALLBACK`| Python bridge | unset | Set to `json` to allow JSON fallback when Arrow encoding is unavailable |
13
-
|`TYWRAP_CODEC_MAX_BYTES`| Python bridge | unset | Reject response payloads larger than this byte count (applied post-reassembly) |
14
-
|`TYWRAP_REQUEST_MAX_BYTES`| Python bridge | unset | Reject request payloads larger than this byte count (applied post-reassembly) |
15
-
|`TYWRAP_TORCH_ALLOW_COPY`| Python bridge | off | Allow GPU-to-CPU or contiguous-copy conversion when serializing `torch.Tensor`|
16
-
|`TYWRAP_ALLOWED_MODULES`| Python bridge | unset | Comma- and/or whitespace-separated import allowlist; blank is unset, while a non-empty value permits only named modules plus bridge-required stdlib modules |
17
-
|`TYWRAP_ALLOW_PRIVATE_ATTRS`| Python bridge | off | Set to `1`, `true`, or `yes` to allow underscore-prefixed attribute access; otherwise it is blocked |
|`TYWRAP_CODEC_FALLBACK`| Python bridge | unset | Set to `json` to allow JSON fallback when Arrow encoding is unavailable |
13
+
|`TYWRAP_CODEC_MAX_BYTES`| Python bridge | unset | Reject response payloads larger than this byte count (applied post-reassembly) |
14
+
|`TYWRAP_REQUEST_MAX_BYTES`| Python bridge | unset | Reject request payloads larger than this byte count (applied post-reassembly) |
15
+
|`TYWRAP_TORCH_ALLOW_COPY`| Python bridge | off | Allow GPU-to-CPU or contiguous-copy conversion when serializing `torch.Tensor`|
16
+
|`TYWRAP_ALLOWED_MODULES`| Python bridge | unset | Comma- and/or whitespace-separated import allowlist; blank is unset, while a non-empty value permits only named modules plus bridge-required stdlib modules. See [SECURITY.md](https://github.com/bbopen/tywrap/blob/main/SECURITY.md).|
17
+
|`TYWRAP_ALLOW_PRIVATE_ATTRS`| Python bridge | off | Set to `1`, `true`, or `yes` to allow underscore-prefixed attribute access; otherwise it is blocked |
0 commit comments