diff --git a/react/Makefile b/react/Makefile new file mode 100644 index 000000000..ce9a9c795 --- /dev/null +++ b/react/Makefile @@ -0,0 +1,3 @@ +pybackend_run: + pip install bottle + python pybackend.py diff --git a/react/pybackend.py b/react/pybackend.py new file mode 100644 index 000000000..5169ea71d --- /dev/null +++ b/react/pybackend.py @@ -0,0 +1,19 @@ +from bottle import run, route, request, response +from anki.pybackend import PythonBackend +from anki import Collection +import sys, os + +path = os.path.expanduser("~/test.anki2") +if not os.path.exists(path): + print(f"to use, copy your collection to {path}") + sys.exit(1) + +col = Collection(path) +backend = PythonBackend(col) + +@route('/request', method="POST") +def proto_request(): + response.content_type = 'application/protobuf' + return backend.run_command_bytes(request.body.read()) + +run(host='localhost', port=5006)