Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
AURA
engine
Commits
dccd6166
Commit
dccd6166
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Template and HTML generation for Track Service.
parent
6ced9558
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api.py
+16
-14
16 additions, 14 deletions
api.py
web/templates/trackservice.html
+19
-0
19 additions, 0 deletions
web/templates/trackservice.html
with
35 additions
and
14 deletions
api.py
+
16
−
14
View file @
dccd6166
...
...
@@ -106,6 +106,10 @@ class EngineApi:
self
.
logger
=
logging
.
getLogger
(
"
engine-api
"
)
self
.
api
=
api
# Generate HTML files
self
.
generate_html
(
"
web/templates/clock.html
"
,
"
web/clock.html
"
)
self
.
generate_html
(
"
web/templates/trackservice.html
"
,
"
web/trackservice.html
"
)
# API Spec
spec
.
components
.
schema
(
"
TrackService
"
,
schema
=
TrackServiceSchema
)
spec
.
components
.
schema
(
"
Report
"
,
schema
=
ReportSchema
)
...
...
@@ -115,7 +119,6 @@ class EngineApi:
# TODO Generates HTML for specification
#self.logger.info(spec.to_yaml())
# Schema instances
EngineApi
.
trackservice_schema
=
TrackServiceSchema
(
many
=
True
)
EngineApi
.
track_schema
=
TrackServiceSchema
()
...
...
@@ -137,7 +140,7 @@ class EngineApi:
# Static resources
@app.route
(
'
/trackservice
'
,
methods
=
[
'
GET
'
])
def
trackservice
():
content
=
open
(
os
.
path
.
join
(
"
contrib/aura-player/public/
"
,
"
index
.html
"
))
content
=
open
(
os
.
path
.
join
(
"
web/
"
,
"
trackservice
.html
"
))
return
Response
(
content
,
mimetype
=
"
text/html
"
)
# Static resources
...
...
@@ -147,14 +150,17 @@ class EngineApi:
return
Response
(
content
,
mimetype
=
"
text/html
"
)
def
generate_html
(
self
):
def
generate_html
(
self
,
src_file
,
target_file
):
"""
Generates HTML based on the configuration options and templates.
Args:
src_file (String): The template file
target_file (String): The HTML file to be generated
"""
template
=
open
(
"
web/templates/clock.html
"
,
"
r
"
)
html
=
open
(
"
web/clock.html
"
,
"
w
"
)
src_file
=
open
(
src_file
,
"
r
"
)
target_file
=
open
(
target_file
,
"
w
"
)
content
=
src_file
.
read
()
config_options
=
{
"
CONFIG-STATION-NAME
"
:
config
.
station_name
,
...
...
@@ -163,16 +169,13 @@ class EngineApi:
"
CONFIG-API-URL
"
:
config
.
exposed_api_url
}
content
=
template
.
read
()
for
key
,
value
in
config_options
.
items
():
content
=
content
.
replace
(
"
:::
"
+
key
+
"
:::
"
,
value
)
html
.
write
(
content
)
templat
e
.
close
()
html
.
close
()
target_file
.
write
(
content
)
src_fil
e
.
close
()
target_file
.
close
()
def
run
(
self
):
"""
...
...
@@ -415,7 +418,6 @@ class ReportResource(Resource):
engine_api
=
EngineApi
(
config
,
api
)
engine_api
.
generate_html
()
if
__name__
==
"
__main__
"
:
engine_api
.
run
()
This diff is collapsed.
Click to expand it.
web/templates/trackservice.html
0 → 100644
+
19
−
0
View file @
dccd6166
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
'utf-8'
>
<meta
name=
'viewport'
content=
'width=device-width,initial-scale=1'
>
<title>
Aura Engine - Track Service
</title>
<link
rel=
'icon'
type=
'image/png'
href=
'/favicon.png'
>
<link
rel=
"stylesheet"
href=
"/bootstrap.css"
>
<link
rel=
'stylesheet'
href=
'/aura.css'
>
<link
rel=
'stylesheet'
href=
'/css/aura-player-bundle.css'
>
<script
defer
src=
'/js/aura-player-bundle.js'
></script>
</head>
<body>
<track-service
api=
":::CONFIG-API-URL:::"
/>
</body>
</html>
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