Client Lambda API¶
The browser client calls the Lambda (lambda-resize) HTTP API for operations that require full frames or video: get-frame, get-movie-data (playback URL), tracking, rotate-and-zip, start-processing, new-frame. The VM (Flask/gunicorn) does not run tracking, serve frames, or serve movie playback URLs.
See ArchitectureDesign.md for the three principles: frames/video → lambda-resize, HTML → flask_app, metadata → flask_api.
Lambda API base URL¶
The server injects the Lambda API base URL into every page via base.html so it is available to all JavaScript as the global LAMBDA_API_BASE:
Set in the template from
get_lambda_api_base()(seeapikey.page_dict()).Example value:
https://your-lambda-api.example.com/If not configured, the variable is empty and client code should skip Lambda calls (e.g. show “Lambda URL not configured”).
All client calls to the Lambda API are authorized: the client sends api_key (and other parameters) in the request; the Lambda validates api_key (e.g. via DynamoDB) before performing the operation.
Endpoints used by the client¶
Operation |
Method |
Path / body |
Purpose |
|---|---|---|---|
Get frame |
GET |
|
Single frame as JPEG |
Get movie data |
GET |
|
Default: 302 redirect to signed S3 URL (movie). |
Status |
GET |
|
Health check |
Track movie |
POST |
|
Body: |
New frame |
POST |
|
Body: |
Rotate and zip |
POST |
|
Body: |
Start processing |
POST |
|
Body: |
Tracking¶
Tracking is requested by POSTing to LAMBDA_API_BASE + 'api/v1' with JSON body:
action:"track-movie"api_key: from the logged-in user (same as other API calls)movie_id: movie to trackframe_start: the edited source frame (0-based). PlantTracer preserves this frame, deletes stored annotations forframe_start + 1 ... end, and resumes tracing at the following frame.
The Lambda validates api_key, resolves user_id, then runs tracking (writes trackpoints and zip to DynamoDB/S3). The client then polls for completion (e.g. via Flask get-movie-metadata with get_all_if_tracking_completed) and updates the UI.
Where the variable is set¶
Template:
src/app/templates/base.html— declaresconst LAMBDA_API_BASE = "{{ lambda_api_base }}";Server:
src/app/apikey.py—page_dict()setslambda_api_basefromget_lambda_api_base()so every page that uses the base template gets the same global.