-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
71 lines (54 loc) · 2.57 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! Importing and launching radenium with a sleep of 0.2 seconds in the fast loop.
#! On an embedded system like ESP, you might want to put there zero.
from Core.Radenium import Radenium
sh = Radenium(runLoopSleep=0.2)
#! Create a home widget on the home page by setting the html for it.
#! This example includes a widget that does not work when in AP mode, that's obvious.
#sh.homeWidget("""<h1>Home page</h1><h2>Weather</h2><div><a href="https://www.buienradar.nl" target="_blank"><img border="0" src="https://image.buienradar.nl/2.0/image/single/RadarMapRainNL?height=512&width=500&renderBackground=True&renderBranding=True&renderText=True"></a>""")
#! Adding the Thermostat App. Make sure that the pattern of your apps or
# services follow:
#! from Apps.[yourappname] import [yourappname]
from Apps.Thermostat import Thermostat
sh.addProcess(Thermostat.Thermostat(sh.process))
#! Adding the simple not finished yet Feedreader app that currently only works on PC's
#! and immediately kill it again, to demonstrate killing of a process.
from Apps.FeedReader import FeedReader
sh.addProcess(FeedReader.FeedReader(sh.process))
#! If you run the framework on a PC and you want to see the feed reader application,
#! comment sh.killProcess('App.FeedReader')
#! If there is any app or service you think should not be running, kill it in a similar way.
sh.killProcess('App.FeedReader')
###############################################################################
#! NO NEED TO EDIT BELOW THESE LINES, UNLESS YOU WANT TO.
###############################################################################
from time import sleep
from _thread import allocate_lock
try:
from MicroWebSrv2 import *
except:
print("Radenium requires MicroWebSrv2, add it to the Radenium directory.")
print("Exciting now.")
exit(0)
@WebRoute(GET, '/', name='Radenium1/1')
def RequestHome(microWebSrv2, request) :
content = sh.httpRequest(request.QueryString, request=request.GetPostedURLEncodedForm())
request.Response.ReturnOk(content)
@WebRoute(POST, '/', name='Radenium1/2')
def RequestHome(microWebSrv2, request) :
content = sh.httpRequest(request.QueryString, request=request.GetPostedURLEncodedForm())
request.Response.ReturnOk(content)
mws2 = MicroWebSrv2()
mws2.SetEmbeddedConfig()
mws2.NotFoundURL = '/'
mws2.StartManaged()
sh.log("You made it till here!")
sh.log("Open a browser and point it to 0.0.0.0:8080 (hardcoded and default ip:port combination)")
sh.log("See you there!")
try :
while mws2.IsRunning :
sh.runOnce()
except KeyboardInterrupt :
pass
sh.halt()
mws2.Stop()
sh.log('Bye')