merton.excel.server

FastAPI app that hosts the merton Excel custom functions.

The Office.js custom-function protocol expects two JSON documents and a JavaScript runtime:

  • GET /functions.json — metadata describing each function, its parameters, and return type.

  • GET /static/functions.html — a tiny HTML page that loads functions.js.

  • GET /static/functions.js — calls CustomFunctions.associate(...) for each function name, forwarding invocations to our POST /call endpoint.

  • POST /call — receives {"function": str, "args": list}, executes the matching Python function, and returns {"result": ...}.

This module is intentionally framework-light: we don’t depend on xlwings-server to keep the dependency footprint small. Anyone who prefers the xlwings-server route can still import merton.excel.functions and register the callables manually.

Functions

build_functions_metadata(→ dict[str, Any])

Construct the functions.json payload Office.js expects.

make_app([namespace])

Build and return the FastAPI app.

run_server(→ None)

Start the FastAPI server with uvicorn.

Module Contents

merton.excel.server.build_functions_metadata() dict[str, Any][source]

Construct the functions.json payload Office.js expects.

merton.excel.server.make_app(namespace: str = 'MERTON')[source]

Build and return the FastAPI app.

Lazy-imports FastAPI so that import merton.excel does not pull in the heavy web stack unless the user is actively starting the server.

merton.excel.server.run_server(host: str = '127.0.0.1', port: int = 8000, *, reload: bool = False) None[source]

Start the FastAPI server with uvicorn.

Used by the merton excel server start CLI command.