fsdb_rest_api
FSDB REST API - Serve Plant Database through RESTful Endpoints
This module provides a RESTful API server for interacting with a local plant database (FSDB). It is designed for the ROMI project and facilitates efficient data handling and retrieval of plant-related datasets. The server enables users to query and manage plant scans, images, point clouds, and other related data files.
Key Features
- Serve a local plant database (FSDB) through RESTful API endpoints.
- Manage plant scans and related data, including images, point clouds, and meshes.
- Retrieve and manage dataset files with various configurations.
- Run in test mode with optional preconfigured datasets or an empty test database.
- Lightweight server setup using Flask, with options for debugging and CORS support.
Environment Variables
ROMI_DB: Path to the directory containing the FSDB. Default: '/myapp/db' (container)PLANTDB_API_PREFIX: Prefix for the REST API URL. Default is empty.PLANTDB_API_SSL: Enable SSL to use an HTTPS scheme. Default isFalse.FLASK_SECRET_KEY: The secret key to use with flask. Default to random (64 bits secret).JWT_SECRET_KEY: The secret key to use with JSON Web Token generator. Default to random (64 bits secret).SESSION_TIMEOUT: Session JWT validity duration in seconds. Default900seconds (15 min).REFRESH_TIMEOUT: Refresh JWT validity duration in seconds. Default86400seconds (1 day).MAX_SESSION: The maximum number of concurrent sessions to allow. Default10.
Usage Examples
To start the REST API server for a local plant database:
python fsdb_rest_api.py --db_location /path/to/your/database --host 127.0.0.1 --port 8080 --debug
To run the server with a temporary test database in debug mode:
python fsdb_rest_api.py --test --debug
For detailed command-line parameters, use the --help flag:
python fsdb_rest_api.py --help
main
Link
main(db_location, host, port, debug, proxy, test, empty, models, log_level)
Entry point for the REST API server using Click.
Source code in plantdb/server/cli/fsdb_rest_api.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
rest_api
Link
rest_api(db_path, proxy=False, url_prefix='', ssl=False, log_level=DEFAULT_LOG_LEVEL, test=False, empty=False, models=False)
Initialize and configure a RESTful API server for Plant Database querying.
This function sets up a Flask application with various RESTful endpoints to enable interaction with a local Plant Database (FSDB). RESTful routes are added for managing and retrieving various datasets and configurations, providing an interface for working with plant scans and related files. The application can be run in test mode with optional configurations for using sample datasets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str or Path or None
|
The path to the local plant database to be served. If set to "/none", the server will raise
an error and terminate unless the path is appropriately overridden in test mode.
If |
required |
|
bool
|
Boolean flag indicating whether the application is behind a reverse proxy, |
False
|
|
str
|
Prefix for all endpoints, by default "" |
''
|
|
str
|
The logging level to use for the application. Defaults to |
DEFAULT_LOG_LEVEL
|
|
bool
|
A boolean flag to specify if the application should run in test mode. When enabled, a test
database will be instantiated with sample datasets or an empty configuration if specified.
Defaults to |
False
|
|
bool
|
A boolean flag to specify whether the test database should be instantiated without any
datasets or configurations. Defaults to |
False
|
|
bool
|
A boolean flag to specify whether the test database should be populated with trained CNN models.
Defaults to |
False
|
Source code in plantdb/server/cli/fsdb_rest_api.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |