before stlite

This commit is contained in:
Lucca Ketterer 2023-01-26 22:55:12 +01:00
parent ec7f2deccc
commit 635682cbf9
2 changed files with 37 additions and 16 deletions

View File

@ -10,6 +10,15 @@ import pickle
import re import re
import webview import webview
# function generate fibonacci sequence
def fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
async def scan_for_pi() -> dict(): async def scan_for_pi() -> dict():
ip = socket.gethostbyname(socket.gethostname()) ip = socket.gethostbyname(socket.gethostname())
baseIP = '.'.join(ip.split(".")[:3]) baseIP = '.'.join(ip.split(".")[:3])
@ -96,22 +105,34 @@ def main(arg):
def run(): def run():
config.set_option('server.headless', True) config.set_option('server.headless', True)
bootstrap.run(gui.__file__, 'streamlit run gui.py --server.headless True', [], di) # bootstrap.run(gui.__file__, 'streamlit run gui.py --server.headless True', [], di)
p = multiprocessing.Process(target=run) # p = multiprocessing.Process(target=run)
p.start() # p.start()
import requests # import requests
while True: # while True:
try: # try:
print(requests.get('http://localhost:8501')) # print(requests.get('http://localhost:8501'))
except: # except:
continue # continue
print('asdf') # print('asdf')
break # break
# cli.main_run(str(gui.__file__)) # cli.main_run(str(gui.__file__))
webview.create_window('LED Control', 'http://localhost:8501') # from streamlit.web.server import Server
# server = Server(gui.__file__, 'streamlit run gui.py --server.headless True')
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", ), ])
application.listen(8888)
webview.create_window('LED Control', application)
webview.start() webview.start()
# proc.terminate() # proc.terminate()
exit() exit()

View File

@ -42,7 +42,6 @@ def main():
def add_to_conf(): def add_to_conf():
st.session_state.config['saved'].append(color) st.session_state.config['saved'].append(color)
init = 0
if 'config' not in st.session_state: if 'config' not in st.session_state:
init = 1 init = 1
st.session_state.config = load_config() st.session_state.config = load_config()
@ -56,7 +55,8 @@ def main():
h = st.slider("Hue", 0.0, 1.0, 0.0, 0.01) h = st.slider("Hue", 0.0, 1.0, 0.0, 0.01)
s = st.slider("Saturation", 0.0, 1.0, 0.0, 0.01) s = st.slider("Saturation", 0.0, 1.0, 0.0, 0.01)
v = st.slider("Value", 0.0, 1.0, 0.0, 0.01) v = st.slider("Value", 0.0, 1.0, 0.0, 0.01)
if init == 0:
r,g,b = colorsys.hsv_to_rgb(h,s,v) r,g,b = colorsys.hsv_to_rgb(h,s,v)
color = rgb_to_hex(int(r * 255),int(g * 255),int(b * 255)) color = rgb_to_hex(int(r * 255),int(g * 255),int(b * 255))