diff options
| author | jsheridan <17163297+jooshkins@users.noreply.github.com> | 2023-03-31 11:01:47 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-31 17:01:47 +0200 |
| commit | e5847cfafb4c8244b964876852c620d2dfa7669b (patch) | |
| tree | f974ebda9db29e185cfd4e9bccac1e08945c2d0c /lib | |
| parent | d3fba192aeea38e0524fbd1f1526edc533098a38 (diff) | |
Feature - Page Preview for Simulator (#2174)
Authored-by: jooshkins
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/api/page_specs.py | 22 | ||||
| -rw-r--r-- | lib/api/server.py | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/api/page_specs.py b/lib/api/page_specs.py new file mode 100644 index 00000000..ff9f7cf6 --- /dev/null +++ b/lib/api/page_specs.py @@ -0,0 +1,22 @@ +# Authors: see git history +# +# Copyright (c) 2010 Authors +# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. + +from flask import Blueprint, g, jsonify + +page_specs = Blueprint('page_specs', __name__) + +@page_specs.route('') +def get_page_specs(): + + metadata = g.extension.get_inkstitch_metadata() + + page_specs = { + "width": metadata.document.get('width'), + "height": metadata.document.get('height'), + "pagecolor": metadata.document[1].get('pagecolor'), + "deskcolor": metadata.document[1].get('inkscape:deskcolor') + } + + return jsonify(page_specs)
\ No newline at end of file diff --git a/lib/api/server.py b/lib/api/server.py index f9bb6458..41a42731 100644 --- a/lib/api/server.py +++ b/lib/api/server.py @@ -19,6 +19,7 @@ from .install import install from .simulator import simulator from .stitch_plan import stitch_plan from .preferences import preferences +from .page_specs import page_specs class APIServer(Thread): @@ -47,6 +48,7 @@ class APIServer(Thread): self.app.register_blueprint(stitch_plan, url_prefix="/stitch_plan") self.app.register_blueprint(install, url_prefix="/install") self.app.register_blueprint(preferences, url_prefix="/preferences") + self.app.register_blueprint(page_specs, url_prefix="/page_specs") @self.app.before_request def store_extension(): |
