Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: export to html when using arrow files (#4645)

Myles Scolnick4e8eace8dd18
diff --git a/frontend/src/core/static/files.ts b/frontend/src/core/static/files.ts
index 80dc309f8f..4fd430e33c 100644
--- a/frontend/src/core/static/files.ts
+++ b/frontend/src/core/static/files.ts
@@ -79,6 +79,16 @@ export function patchVegaLoader(
function maybeGetVirtualFile(url: string): string | undefined {
const pathname = new URL(url, document.baseURI).pathname;
+
+ // If if the URL starts with file://, then using the document.baseURI
+ // will not work. In this case, should just chop off from /@file/...
+ if (url.startsWith("file://")) {
+ const indexOfFile = url.indexOf("/@file/");
+ if (indexOfFile !== -1) {
+ url = files[url.slice(indexOfFile)];
+ }
+ }
+
// Few variations to grab the URL.
// This can happen if a static file was open at file:// or https://
return (
diff --git a/marimo/_server/export/exporter.py b/marimo/_server/export/exporter.py
index 87f17f457b..82abf734eb 100644
--- a/marimo/_server/export/exporter.py
+++ b/marimo/_server/export/exporter.py
@@ -84,10 +84,7 @@ class Exporter:
e,
)
continue
- mime_type, _ = mimetypes.guess_type(basename) or (
- "text/plain",
- None,
- )
+ mime_type = mimetypes.guess_type(basename)[0] or "text/plain"
files[filename_and_length] = build_data_url(
cast(KnownMimeType, mime_type),
base64.b64encode(buffer_contents),