Closed MominIqbal-1234 closed 7 months ago
I'm hitting this too. I've added:
[component.blah]
source = "app.wasm"
files = [{ source = "", destination = "/" }]
Then:
def read_file():
with open(file="index.html", mode="r") as f:
return f.read()
Thanks for reporting this. I'm planning to look into it on Tuesday.
[component.myapi] source = "app.wasm" files = [{ source = "", destination = "/" }]
from spin_sdk import http
from spin_sdk.http import Request, Response, send
class IncomingHandler(http.IncomingHandler): def handle_request(self, request: Request) -> Response: with open(file="index.html", mode="r") as f: html = f.read() print(html) return Response(200, {"content-type": "text/plain"}, bytes(f"Hello World", "utf-8"))
mefizapi: http://127.0.0.1:3000 (wildcard) Traceback (most recent call last): File "/1/spin_sdk/http/init.py", line 88, in handle File "/0/app.py", line 7, in handle_request FileNotFoundError: [Errno 44] No such file or directory: 'index.html'
I have a fix for this, but it requires changes to wasi-libc
, componentize-py
, and spin-python-sdk
, so it will take some time to roll out. I'm currently waiting for GitHub Actions to build my temporary fork of wasi-sdk
(which includes the wasi-libc
patch). Once that's done, I'll make a componentize-py
0.13.1 release, and once that's done, I'll make a new spin-python-sdk
release with the fix.
thanks so much, i am waiting release :)
This should be fixed in v3.0.0, which I just released: https://pypi.org/project/spin-sdk/3.0.0/
Traceback (most recent call last): File "/1/spin_sdk/http/init.py", line 88, in handle File "/0/app.py", line 7, in handle_request FileNotFoundError: [Errno 44] No such file or directory: 'myfile.txt'
this file is available in the same directory