Skip to content

Commit 10c77df

Browse files
committed
works
1 parent 729805e commit 10c77df

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

example/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pyscript import PyWorker
33

44
config = {
5-
"packages": ["fsspec", "fastparquet"],
5+
"packages": ["fsspec", "fastparquet", "pandas"],
66
"files": {
77
"./pyscript_fsspec_client/__init__.py": "./pyscript_fsspec_client/__init__.py",
88
"./pyscript_fsspec_client/client.py": "./pyscript_fsspec_client/client.py",

example/server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import sys
55

66

7+
# Alternative way to achieve the same thing, with extra options:
8+
# > uv run https://https://raw.githubusercontent.com/antocuni/env/refs/heads/master/bin/cors-server.py
9+
# or
10+
# > uvx pyscript run
711
class ExtraHeadersHandler(http.server.SimpleHTTPRequestHandler):
812
directory = os.path.dirname(__file__) if "__file__" in locals() else os.getcwd()
913

example/worker.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from pyscript import sync, ffi
22

33
import fsspec
4+
from pyscript import display, fetch, window
5+
from pyscript.web import span, page
6+
import pandas as pd
47
import pyscript_fsspec_client.client
58

69
fs = fsspec.filesystem("pyscript")
@@ -13,3 +16,13 @@
1316
print("binary:", type(out), out)
1417

1518
fs.pipe_file("local/mdurant/code/fsspec-proxy/OUTPUT", b"hello world")
19+
20+
21+
def make_output(table):
22+
"""put HTML on the page"""
23+
new_div = span()
24+
new_div.innerHTML = table
25+
page.append(new_div)
26+
27+
my_data = pd.read_parquet("pyscript://Conda Stats/2017/01/2017-01-07.parquet")
28+
make_output(my_data[:100].to_html())

pyscript-fsspec-client/pyscript_fsspec_client/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ def _call(self, path, method="GET", range=None, binary=False, data=0, json=0):
4848
return out
4949

5050
def ls(self, path, detail=True, **kwargs):
51+
print(path)
5152
path = self._strip_protocol(path)
5253
key, *path = path.split("/", 1)
5354
if key:
5455
part = path[0] if path else ""
55-
out = self._call(f"{key}/list/{part}")
56+
out = loads(self._call(f"{key}/list/{part}"))["contents"]
5657
else:
5758
raise ValueError
5859

60+
print(out)
5961
if detail:
6062
return out
6163
return sorted(_["name"] for _ in out)

0 commit comments

Comments
 (0)