https://github.com/michellen/python-wasm-component
python http app as wasm component
https://github.com/michellen/python-wasm-component
Last synced: 2 months ago
JSON representation
python http app as wasm component
- Host: GitHub
- URL: https://github.com/michellen/python-wasm-component
- Owner: michelleN
- License: apache-2.0
- Created: 2023-11-02T22:05:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-03T15:29:15.000Z (over 1 year ago)
- Last Synced: 2025-02-01T14:14:11.059Z (4 months ago)
- Language: Python
- Size: 9.68 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-wasm-component
Build a wasm component from a python http app
1. Create a wit directory with a world that conforms to an http trigger which essentially means you need a world that exports
a wasi http incoming handler type2. Generate bindings using [componentize-py](https://github.com/bytecodealliance/componentize-py). By default, bindings will be created in a directory with the same name as the world you are targeting (replacing hyphens with underscores).
```bash
componentize-py -d wit -w http-app bindings .
```3. Create the http handler in app.py using imports from the bindings that were generated.
4. Run `spin up --build` to build and run your component. Under the hood `spin build` is running `componentize-py -d wit -w http-app componentize app -o app.wasm` which builds you WASM component and outputs it as `app.wasm`.
5. Test using curl
```console
$ curl -i localhost:3000
HTTP/1.1 200 OK
hello: WORLD
content-length: 0
date: Thu, 02 Nov 2023 22:25:33 GMT
```Enjoy!