Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DataCatalog
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
eFlows4HPC WP2
DataCatalog
Commits
e2096c9f
Commit
e2096c9f
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
create static now can configure the api url from env variable
parent
e39e6b7e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/createStatic.py
+18
-2
18 additions, 2 deletions
frontend/createStatic.py
frontend/js/apicalls.js
+1
-1
1 addition, 1 deletion
frontend/js/apicalls.js
with
19 additions
and
3 deletions
frontend/createStatic.py
+
18
−
2
View file @
e2096c9f
...
...
@@ -2,7 +2,10 @@ from jinja2 import Environment, FileSystemLoader
import
os
import
shutil
def
render_template_to_site
():
API_URL_ENV_VARNAME
=
"
DATACATALOG_API_URL
"
API_URL_DEFAULT_VALUE
=
"
http://localhost:8000/
"
def
render_template_to_site
(
api_url
=
API_URL_DEFAULT_VALUE
):
## copy javascript files to site folder
src_files
=
os
.
listdir
(
'
frontend/js
'
)
dest
=
'
site/js
'
...
...
@@ -23,6 +26,16 @@ def render_template_to_site():
if
os
.
path
.
isfile
(
full_name
):
shutil
.
copy
(
full_name
,
dest
)
## replace {{API_URL}} tag with actual api url from env
apicalls_file_path
=
'
site/js/apicalls.js
'
api_tag
=
'
{{API_URL}}
'
with
open
(
apicalls_file_path
,
'
r
'
)
as
file
:
filedata
=
file
.
read
()
filedata
=
filedata
.
replace
(
api_tag
,
api_url
)
with
open
(
apicalls_file_path
,
'
w
'
)
as
file
:
file
.
write
(
filedata
)
## render templates to site folder
file_loader
=
FileSystemLoader
(
'
frontend/templates
'
)
env
=
Environment
(
loader
=
file_loader
)
...
...
@@ -52,4 +65,7 @@ def render_template_to_site():
f
.
write
(
html
[
file
])
if
__name__
==
"
__main__
"
:
render_template_to_site
()
\ No newline at end of file
# if env variable is set, get api url from it, else use default
api_url
=
os
.
getenv
(
API_URL_ENV_VARNAME
,
API_URL_DEFAULT_VALUE
)
# TODO if argument is there, set api url
render_template_to_site
(
api_url
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/js/apicalls.js
+
1
−
1
View file @
e2096c9f
// This file contains the api calls, as well as transform the data into html-text
var
apiUrl
=
"
http://zam024.fritz.box/api/
"
;
// TODO switch out with real url, ideally during deployment
var
apiUrl
=
"
{{API_URL}}
"
;
var
allowedTypesList
=
[];
// get data from url query variables
...
...
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