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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
/* Copyright 2026 Marimo. All rights reserved. */
import { downloadExportedFile } from "@/utils/download";
import { getExportLayout } from "../export/layout";
import { getRequestClient } from "../network/requests";
import { VirtualFileTracker } from "./virtual-file-tracker";
/**
* Downloads the current notebook as an HTML file.
*/
export async function downloadAsHTML(opts: { includeCode: boolean }) {
const client = getRequestClient();
const { includeCode } = opts;
const exportedFile = await client.exportAsHTML({
download: true,
includeCode: includeCode,
files: VirtualFileTracker.INSTANCE.filenames(),
layout: await getExportLayout(),
});
downloadExportedFile(exportedFile);
}
function updateAssetUrl(existingUrl: string, assetBaseUrl: string) {
// Will convert: https://localhost:8080/assets/index-c78b8d10.js
// Or will convert ./assets/index-c78b8d10.js
// Or will convert /assets/index-c78b8d10.js
// into: https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index-c78b8d10.js
// relative './...'
if (existingUrl.startsWith("./")) {
return `${assetBaseUrl}${existingUrl.slice(1)}`;
}
// relative '/...'
if (existingUrl.startsWith("/")) {
return `${assetBaseUrl}${existingUrl}`;
}
// absolute path
const url = new URL(existingUrl);
if (url.origin !== window.location.origin) {
return `${assetBaseUrl}${url.pathname}`;
}
// otherwise, leave as is
return existingUrl;
}
export const visibleForTesting = {
updateAssetUrl,
};