Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
StorageLeaf
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ProjectLeaf
StorageLeaf
Commits
40372d83
Commit
40372d83
authored
4 years ago
by
Robert Goldmann
Browse files
Options
Downloads
Patches
Plain Diff
externalized device routes
parent
f27ebdca
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/StorageLeaf.py
+3
-1
3 additions, 1 deletion
src/StorageLeaf.py
src/blueprints/Devices.py
+39
-0
39 additions, 0 deletions
src/blueprints/Devices.py
src/blueprints/Routes.py
+0
-19
0 additions, 19 deletions
src/blueprints/Routes.py
with
42 additions
and
20 deletions
src/StorageLeaf.py
+
3
−
1
View file @
40372d83
...
@@ -3,7 +3,7 @@ import os
...
@@ -3,7 +3,7 @@ import os
from
TheCodeLabs_BaseUtils.DefaultLogger
import
DefaultLogger
from
TheCodeLabs_BaseUtils.DefaultLogger
import
DefaultLogger
from
TheCodeLabs_FlaskUtils.FlaskBaseApp
import
FlaskBaseApp
from
TheCodeLabs_FlaskUtils.FlaskBaseApp
import
FlaskBaseApp
from
blueprints
import
Routes
from
blueprints
import
Routes
,
Devices
from
logic
import
Constants
from
logic
import
Constants
LOGGER
=
DefaultLogger
().
create_logger_if_not_exists
(
Constants
.
APP_NAME
)
LOGGER
=
DefaultLogger
().
create_logger_if_not_exists
(
Constants
.
APP_NAME
)
...
@@ -15,6 +15,8 @@ class StorageLeaf(FlaskBaseApp):
...
@@ -15,6 +15,8 @@ class StorageLeaf(FlaskBaseApp):
def
_register_blueprints
(
self
,
app
):
def
_register_blueprints
(
self
,
app
):
app
.
register_blueprint
(
Routes
.
construct_blueprint
(
self
.
_settings
,
self
.
_version
))
app
.
register_blueprint
(
Routes
.
construct_blueprint
(
self
.
_settings
,
self
.
_version
))
app
.
register_blueprint
(
Devices
.
construct_blueprint
(
self
.
_settings
))
return
app
return
app
...
...
This diff is collapsed.
Click to expand it.
src/blueprints/Devices.py
0 → 100644
+
39
−
0
View file @
40372d83
from
enum
import
Enum
from
flask
import
Blueprint
,
jsonify
from
logic.Database
import
Database
class
DeviceParameters
(
Enum
):
DEVICE
=
'
device
'
SENSORS
=
'
sensors
'
@staticmethod
def
get_values
():
return
[
m
.
value
for
m
in
DeviceParameters
]
def
construct_blueprint
(
settings
):
devices
=
Blueprint
(
'
devices
'
,
__name__
)
@devices.route
(
'
/devices
'
,
methods
=
[
'
GET
'
])
def
get_all_devices
():
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
return
jsonify
(
database
.
deviceAccess
.
get_all_devices
())
@devices.route
(
'
/device/<int:deviceID>
'
,
methods
=
[
'
GET
'
])
def
get_device
(
deviceID
):
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
return
jsonify
(
database
.
deviceAccess
.
get_device
(
deviceID
))
@devices.route
(
'
/device/<int:deviceID>/sensors/
'
,
methods
=
[
'
GET
'
])
def
get_all_sensors_for_device
(
deviceID
):
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
device
=
database
.
deviceAccess
.
get_device
(
deviceID
)
if
not
device
:
return
jsonify
({
'
success
'
:
False
,
'
msg
'
:
f
'
No device with id
"
{
deviceID
}
"
existing
'
})
return
jsonify
(
database
.
sensorAccess
.
get_all_sensors_for_device
(
deviceID
))
return
devices
This diff is collapsed.
Click to expand it.
src/blueprints/Routes.py
+
0
−
19
View file @
40372d83
...
@@ -48,16 +48,6 @@ def construct_blueprint(settings, version):
...
@@ -48,16 +48,6 @@ def construct_blueprint(settings, version):
appName
=
Constants
.
APP_NAME
,
appName
=
Constants
.
APP_NAME
,
openApiSpecification
=
specification
)
openApiSpecification
=
specification
)
@routes.route
(
'
/devices
'
,
methods
=
[
'
GET
'
])
def
get_all_devices
():
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
return
jsonify
(
database
.
deviceAccess
.
get_all_devices
())
@routes.route
(
'
/device/<int:deviceID>
'
,
methods
=
[
'
GET
'
])
def
get_device
(
deviceID
):
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
return
jsonify
(
database
.
deviceAccess
.
get_device
(
deviceID
))
@routes.route
(
'
/sensors
'
,
methods
=
[
'
GET
'
])
@routes.route
(
'
/sensors
'
,
methods
=
[
'
GET
'
])
def
get_all_sensors
():
def
get_all_sensors
():
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
...
@@ -68,15 +58,6 @@ def construct_blueprint(settings, version):
...
@@ -68,15 +58,6 @@ def construct_blueprint(settings, version):
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
return
jsonify
(
database
.
sensorAccess
.
get_sensor
(
sensorID
))
return
jsonify
(
database
.
sensorAccess
.
get_sensor
(
sensorID
))
@routes.route
(
'
/device/<int:deviceID>/sensors/
'
,
methods
=
[
'
GET
'
])
def
get_all_sensors_for_device
(
deviceID
):
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
device
=
database
.
deviceAccess
.
get_device
(
deviceID
)
if
not
device
:
return
jsonify
({
'
success
'
:
False
,
'
msg
'
:
f
'
No device with id
"
{
deviceID
}
"
existing
'
})
return
jsonify
(
database
.
sensorAccess
.
get_all_sensors_for_device
(
deviceID
))
@routes.route
(
'
/measurements
'
,
methods
=
[
'
GET
'
])
@routes.route
(
'
/measurements
'
,
methods
=
[
'
GET
'
])
def
get_all_measurements
():
def
get_all_measurements
():
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
database
=
Database
(
settings
[
'
database
'
][
'
databasePath
'
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment