-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig_full.py
79 lines (66 loc) · 4.46 KB
/
config_full.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
72
73
74
75
76
77
78
79
"""
This is an example config module for a pootleweb web server.
It provides all the info needed to start and run a webserver using pootleweb, with the various parts explained.
This module is loaded by webserv.py and various entries are used by webserv.py to start the webserver.
"""
from pootlestuff import basichttpserver as httpbase # this module should contain the classes httpserver and httprequh
from pootlestuff.watchables import loadsettings
import pathlib, sys
import stepperweb
######################################################################################################
# The following fields are used directly by webserv.py
######################################################################################################
# set the loglevel - 10 for DEBUG, 20 for INFO, 40 for ERROR, 50 for FATAL (bigger the value, less is logged)
loglevel=10
# defines the log format used for logging direct to stderr. console log is switch on using -v param to webserv from
# the shell command. Without -v this is ignored.
consolelogformat={
'fmt' : '%(asctime)s %(levelname)7s (%(process)d)%(threadName)12s %(module)s.%(funcName)s: %(message)s',
'datefmt' : "%M:%S",
}
# a logfile can be specified in the shell command (-l) if the shell command option is specified it overrides any value here
# logfile='log.log' # uncomment to use logfile
#this specifies the port used for this web server
webport = 8000
# This is the class used to create the webserver
httpserverclass = httpbase.httpserver
# this is the class instantiated to handle each incoming http request
httprequestclass = httpbase.httprequh
settingsfile = None # default motor settings file
def setup(settings):
app1 = stepperweb.webapp(value=settingsfile if settings is None else settings)
ddef = {
'staticroot' : {'path':pathlib.Path(__file__).parent/'static', 'root':'/stat/'}, # specifies the folder in which static files are found
'app' : app1,
'GET' : { # all valid GETs and what to do with them. each entry is a 2-tuple, with a keyword used by the httprequest handler to
# select how to process the request.
'' : ('redirect', '/index.html'),
'full.html' : ('makedynampage', (app1.makeMainPage,{
'page': 'templates/everything.html',
'topfields': ('pigpmspw', 'pigpppw', 'pigpbpw', 'mode', 'max_waves', 'max_wave_time', 'wavepulses', 'doitnow'),
'motorfields': {'a4988m1': {'fields':('usercmd', 'userpos', 'userdir', 'userstepm', 'opmode', 'targetrawpos', 'rawposn',
'drive_enable', 'direction', 'step', 'holdstopped', 'activestepm'),
'stepfields': 1},
'a4988m2': {'fields': ('usercmd', 'userpos', 'userdir', 'userstepm', 'opmode', 'targetrawpos', 'rawposn',
'drive_enable', 'direction', 'step', 'holdstopped', 'activestepm'),
'stepfields': 1},
'byj': {'fields': ('usercmd', 'userpos', 'userdir', 'userstepm', 'opmode', 'targetrawpos', 'rawposn',
'drive_pins', 'holdstopped', 'activestepm'),
'stepfields': 1},
}})),
'index.html' : ('makedynampage', (app1.makeMainPage,{
'page': 'templates/compact.html',
'topfields': ('mode', 'doitnow'),
'motorfields': {'a4988m1': {'fields':('usercmd', 'userpos', 'userdir', 'userstepm', 'opmode', 'targetrawpos', 'rawposn'),
'stepfields': 0},
'a4988m2': {'fields': ('usercmd', 'userpos', 'userdir', 'userstepm', 'opmode', 'targetrawpos', 'rawposn'),
'stepfields': 0},
'byj': {'fields': ('usercmd', 'userpos', 'userdir', 'userstepm', 'opmode', 'targetrawpos', 'rawposn',
'drive_pins', 'holdstopped', 'activestepm'),
'stepfields': 0},
}})),
'appupdates' : ('updatestream', ('serv', 'getupdates')),
'updateSetting' : ('updatewv', 0),
},
}
return ddef