Backend on Python, frontend on JavaScript – interactions in case of strong restrictions

I’m looking for ways to ensure interaction between a backend on Python and a frontend on javascript/html under strict conditions:

  • usage of Python with a minimal set of libraries (what can be installed manually from archives from pypi.org)
  • JQuery’s and Popper’s js-files are used locally
  • has no package installers and runners like npm and npx
  • it is impossible to use runtimes and frameworks like NodeJs and Flask etc, as well as libraries with a large number of dependencies
  • no Internet access, i.e. have no access to remote runtimes like PyScript

Is there a way to do this?

I’ve tested PyScript, but didn’t find the way to use it locally and without installation (which need npx and npm).
I also tried ajax requests like here

`$.ajax({
  type: "POST",
  url: "~/pythoncode.py",
  data: { param: text}
}).done(function( o ) {
   // do something
});`

but it doesn’t work, probably I’ve made it incorrectly.

I want to use my Python classes and functions of backend in my frontend on JavaScript.