Skip to content

HTTP API for capture, pause and change engine#75

Open
meh3lp wants to merge 2 commits into
AuroraWright:masterfrom
meh3lp:master
Open

HTTP API for capture, pause and change engine#75
meh3lp wants to merge 2 commits into
AuroraWright:masterfrom
meh3lp:master

Conversation

@meh3lp
Copy link
Copy Markdown

@meh3lp meh3lp commented Mar 14, 2026

Overview

Use the built-in http.server to expose:

  • state_handlers.engine_change_handler
  • state_handlers.pause_handler
  • screenshot_request_queue.put

Serve new file api.html containing API documentation on GET requests

Add api-related options to config:

  • api_enabled = False
  • api_host = localhost
  • api_port = 7332

Why

Though this can have a variety of applications, the goal is to provide another solution for keybinds on wayland as most DEs I know of offer a native way to bind keys to custom commands.
For example, this can be used on hyprland to bind screenshot capture to Ctrl+Alt+O:
~/.config/hypr/hyprland.conf
bind = Ctrl+Alt, O, exec, curl -X POST http://localhost:7332/action/capture

Limitations

The documentation file is read at path owocr/api.html which works in dev environment, but I haven't tested if it will work in a build and I did not dive deep enough into the codebase to figure it out.
content = Path("owocr/api.html").read_bytes()
If it turns out to cause issues consider reverting commit 4e5346 and only keeping commit eca493 which contains the core post request handlers.

There is no authentication, meaning the server blindly trusts any request it receives. While none of the exposed functionality is immediately exploitable and I expect users to have the server behind a firewall anyway, implementing authentication should be a consideration if the API functionality is expanded in the future.

This pull request only implements handlers necessary to fix keybinds on wayland, more work is needed to expose full control over all features of owocr

The built-in http.server is not suited for anything remotely complex, so if there's ever need for more API features the thing better be rewritten with flask of fastapi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant