Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Chris
Pixelframe
Commits
5e26a219
Commit
5e26a219
authored
Dec 22, 2020
by
Christian Wander
Browse files
begin with initial config stuff
parent
c40bfc6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
pixelframe/controllers.py
View file @
5e26a219
from
pixelframe
import
app
from
flask
import
render_template
from
flask
import
render_template
,
request
import
pixelframe.pixel_service
as
pixel_service
import
pixelframe.image_config
as
config
@
app
.
route
(
'/'
)
def
main_page
():
return
render_template
(
'main.html'
)
return
"This is the main page"
@
app
.
route
(
'/hello'
)
def
hello_method
():
return
render_template
(
'hello.html'
,
name
=
"foo"
)
@
app
.
route
(
'/start'
,
methods
=
[
"POST"
])
def
start_pixels
():
pixel_service
.
doit
()
return
"Started work."
@
app
.
route
(
'/stop'
,
methods
=
[
"POST"
])
def
stop_pixels
():
pixel_service
.
stopit
()
return
"Stopped work"
@
app
.
route
(
'/images'
,
methods
=
[
"GET"
,
"POST"
])
def
images
():
"""
Endpoint used to set/get the image configuration
"""
if
request
.
method
==
'POST'
:
print
(
f
'>> receiving:
{
request
.
json
}
'
)
config
.
update
(
request
.
json
)
return
config
.
config
pixelframe/image_config.py
0 → 100644
View file @
5e26a219
config
=
{
"path"
:
"data"
,
"images"
:
[
"creeper-12x12.png"
,
"cyber-12x12.png"
,
"star2-12x12.png"
,
"heart-ping-12x12.png"
]
}
def
update
(
data
):
# TODO: Check if there's something better to validate json data
print
(
f
'>> updating config:
{
data
}
'
)
if
"images"
in
data
:
config
[
'images'
]
=
data
[
'images'
]
if
"path"
in
data
:
config
[
'path'
]
=
data
[
'path'
]
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment