How to use the webserver.addHtml function in webserver

To help you get started, we’ve selected a few webserver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enesbcs / rpieasy / _C020_LoraDirect.py View on Github external
optionvalues = [10,100,1000]
   webserver.addFormSelector("Duty cycle","duty",len(optionvalues),options,optionvalues,None,self.duty)
   webserver.addFormNote("Please check your local Duty cycle regulations for your selected frequency!")

   webserver.addFormNumericBox("Spreading factor","spreading",self.sf,6,12)
   options = ["7.8","10.4","15.6","20.8","31.25","41.7","62.5","125","250","500"]
   optionvalues = [BW.BW7_8, BW.BW10_4, BW.BW15_6, BW.BW20_8, BW.BW31_25, BW.BW41_7, BW.BW62_5, BW.BW125, BW.BW250, BW.BW500]
   webserver.addFormSelector("Bandwidth","bw",len(optionvalues),options,optionvalues,None,self.bw)
   webserver.addUnit("khz")

   options = ["CR4/5","CR4/6","CR4/7","CR4/8"]
   optionvalues = [CODING_RATE.CR4_5,CODING_RATE.CR4_6,CODING_RATE.CR4_7,CODING_RATE.CR4_8]
   webserver.addFormSelector("Coding rate","coding",len(optionvalues),options,optionvalues,None,self.coding)

   webserver.addFormNumericBox("Sync Word","sync",self.sync,0,255)
   webserver.addHtml("( 0x"+format(self.sync, '02x')+" )")
   webserver.addFormNote("Default 0x12, LoRaWAN is 0x34. Nodes can only communicate each other if uses same sync word!")

   webserver.addFormCheckBox("Enable Sending","sender",self.enablesend)
   webserver.addFormNumericBox("Default destination node index","defaultnode",self.defaultunit,0,255)
   webserver.addFormNote("Default node index for data sending")
  except Exception as e:
   misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,str(e))
  return True
github enesbcs / rpieasy / _C022_ESPNow.py View on Github external
webserver.sendHeadandTail("TmplStd",webserver._TAIL)
    return webserver.TXBuffer

   elif taskmode and int(tasknum)>0: # display plugin selection
    webserver.TXBuffer += "<form method="post" name="frmadd"><table class="normal"><tbody><tr><td><input value="&quot;+str(managenode)+&quot;" name="nodenum" type="hidden"><input value="&quot;+str(tasknum2)+&quot;" name="tasknum" type="hidden">")
    webserver.addSubmitButton("Save task", "savetask")
    webserver.addButton("espnow","Back")

    webserver.TXBuffer += "</td></tr></tbody></table>"
    try:
       if ("," in taska):
        ts = str(taska).split(",")
        tasknum2 = int(ts[1])
       else:
        tasknum2 = int(taska[1])
    except:
       tasknum2 = int(tasknum)
    webserver.addFormHeader("ESPNow add new task "+str(tasknum2)+" on Node "+str(managenode))
    displaytask(taska,taskc)
    webserver.addHtml("</form>"
    webserver.sendHeadandTail("TmplStd",webserver._TAIL)
    return webserver.TXBuffer

   elif taskmode and str(managenode)!="": # display tasklist
    webserver.TXBuffer += "<form method="post" name="frmtask"><table class="normal"></table>"
    webserver.addFormHeader("ESPNow tasklist")
    tasks = []
    confs = []
    if str(managenode)=="local": #serial node
     webserver.addFormHeader("Serial node")
     commands.doExecuteCommand("serialcommand,espnow,tasklist",False)
     time.sleep(3)</form>
github enesbcs / rpieasy / _C020_LoraDirect.py View on Github external
def webform_load(self):
  webserver.addFormNote("IP and Port parameter is not used!")
  webserver.addFormNote("SX127x hardware supported by pyLoRa library")
  webserver.addHtml("<p>Example sender sketches could be find <a href="https://github.com/enesbcs/EasyLora">here</a>.")
#  if self.lora is not None:
#    webserver.addFormNote("LoRa version: "+str(self.lora.get_version()))
  try:
   webserver.addTableSeparator("Hardware settings",2,3)
   if BOARD.SPI_BUS==0:
    webserver.addHtml("SPI0 selected<i>(MOSI=GPIO10, MISO=GPIO9, SCK=GPIO11, NSS=GPIO8)</i>")
    spiok = False
    if gpios.HWPorts.is_spi_usable(BOARD.SPI_BUS):
     if gpios.HWPorts.is_spi_enabled(BOARD.SPI_BUS):
      webserver.addHtml(" - <b>SPI0 enabled</b>")
      spiok = True
    if spiok==False:
     webserver.addHtml("Enable SPI0 first at hardware <a href="pinout">pinout page</a>!")
   else:
     webserver.addHtml("You have modified BOARD constants, so you are an expert!")
   webserver.addHtml("DIO0 (IRQ)GPIO"+str(BOARD.DIO0))</p>
github enesbcs / rpieasy / _C022_ESPNow.py View on Github external
def webform_load(self):
  webserver.addFormNote("IP and Port parameter is not used!")
  try:
   choice1 = self.port
   options = rpiSerial.serial_portlist()
   if len(options)&gt;0:
    webserver.addHtml("Serial Device:")
    webserver.addSelector_Head("ser_addr",False)
    for o in range(len(options)):
     webserver.addSelector_Item(options[o],options[o],(str(options[o])==str(choice1)),False)
    webserver.addSelector_Foot()
    webserver.addFormNote("For RPI use 'raspi-config' tool: 5- Interfacing Options-P6 Serial- (Kernel logging disabled + serial port hardware enabled) before enable this plugin")
    webserver.addFormNumericBox("Baudrate","ser_spd",self.baud,50,4000000)
    webserver.addFormNote("Generic values: 9600, 19200, 38400, 57600, 115200")
#    webserver.addFormCheckBox("Enable Sending","sender",self.enablesend)
    webserver.addFormNumericBox("Default destination node index","defaultnode",self.defaultunit,0,255)
    webserver.addFormNote("Default node index for data sending")
    webserver.addFormNote("Detected gateway MAC address "+str(self.mac))
    options = []
    optionvalues = []
    for i in range(1,14):
       options.append(str(i))
       optionvalues.append(i)
github enesbcs / rpieasy / _P023_OLED.py View on Github external
webserver.addFormSelector("Address","p023_adr",len(options),options,optionvalues,None,choice2)
  webserver.addFormNote("Enable <a href="pinout">I2C bus</a> first, than <a href="i2cscanner">search for the used address</a>!")
  choice3 = int(float(self.taskdevicepluginconfig[2])) # store rotation state
  options =      ["Normal","Rotate by 90","Rotate by 180","Rotate by 270"]
  optionvalues = [0,1,2,3]
  webserver.addFormSelector("Mode","p023_rotate",len(optionvalues),options,optionvalues,None,choice3)
  options = ["Default","128x64","128x128","128x32","96x96","96x64","64x48","64x32"]
  choice4 = self.taskdevicepluginconfig[3] # store resolution
  webserver.addHtml("Resolution:")
  webserver.addSelector_Head("p023_res",False)
  for d in range(len(options)):
   webserver.addSelector_Item(options[d],options[d],(choice4==options[d]),False)
  webserver.addSelector_Foot()

  choice5 = int(float(self.taskdevicepluginconfig[4])) # store line count
  webserver.addHtml("Number of lines:")
  webserver.addSelector_Head("p023_linecount",False)
  for l in range(1,self.P23_Nlines+1):
   webserver.addSelector_Item(str(l),l,(l==choice5),False)
  webserver.addSelector_Foot()
  webserver.addFormNumericBox("Try to display # characters per row","p023_charperl",self.taskdevicepluginconfig[5],1,32)
  webserver.addFormNote("Leave it '1' if you do not care")
  webserver.addFormCheckBox("Clear only used lines","p023_partialclear",self.taskdevicepluginconfig[6])
  if choice5 &gt; 0 and choice5&lt;9:
   lc = choice5
  else:
   lc = self.P23_Nlines
  for l in range(lc):
   try:
    linestr = self.lines[l]
   except:
    linestr = ""
github enesbcs / rpieasy / _P201_GenSerial.py View on Github external
def webform_load(self):
  choice1 = self.taskdevicepluginconfig[0]
  options = rpiSerial.serial_portlist()
  if len(options)&gt;0:
   webserver.addHtml("Serial Device:")
   webserver.addSelector_Head("p201_addr",False)
   for o in range(len(options)):
    webserver.addSelector_Item(options[o],options[o],(str(options[o])==str(choice1)),False)
   webserver.addSelector_Foot()
   webserver.addFormNote("For RPI use 'raspi-config' tool: 5- Interfacing Options-P6 Serial- (Kernel logging disabled + serial port hardware enabled) before enable this plugin")
   webserver.addFormNumericBox("Baudrate","p201_spd",self.taskdevicepluginconfig[1],50,4000000)
   webserver.addFormNote("Generic values: 9600, 19200, 38400, 57600, 115200")
   choice2 = self.taskdevicepluginconfig[2]
   options = ["5","6","7","8"]
   optionvalues = [rpiSerial.FIVEBITS,rpiSerial.SIXBITS,rpiSerial.SEVENBITS,rpiSerial.EIGHTBITS]
   webserver.addFormSelector("Bytesize","p201_bsize",len(optionvalues),options,optionvalues,None,int(choice2))
   webserver.addFormNote("Most common setting is 8")
   choice3 = self.taskdevicepluginconfig[3]
   options = ["None","Even","Odd","Mark","Space"]
   optionvalues = [rpiSerial.PARITY_NONE,rpiSerial.PARITY_EVEN,rpiSerial.PARITY_ODD,rpiSerial.PARITY_MARK,rpiSerial.PARITY_SPACE]
   webserver.addHtml("Parity:")
github enesbcs / rpieasy / _P508_Temper.py View on Github external
def webform_load(self):
  choice1 = self.taskdevicepluginconfig[0]
  try:
   options = utemper.get_select_list()
  except:
   options = []
  if len(options)&gt;0:
   webserver.addHtml("Device:")
   webserver.addSelector_Head("p508_addr",True)
   for o in range(len(options)):
    webserver.addSelector_Item(str(options[o][1])+" "+str(options[o][2]),int(o+1),(str(o+1)==str(choice1)),False)
   webserver.addSelector_Foot()
   choice2 = self.taskdevicepluginconfig[1]
   options = ["Internal temp","External temp", "Internal temp+humidity", "External temp+humidity"]
   optionvalues = [0,1,2,3]
   webserver.addFormSelector("Sensor type","p508_type",len(optionvalues),options,optionvalues,None,choice2)
  webserver.addFormNote("Without root rights you will not see any Temper device!")
  return True
github enesbcs / rpieasy / _P505_VLCAudio.py View on Github external
def webform_load(self):
  if Settings.SoundSystem["usable"]==False:
   webserver.addHtml("<font color="red">The sound system can not be used!</font>")
  else:
   maxlevel = rpieGlobals.PLUGIN_CONFIGVAR_MAX
   if maxlevel&gt;10:
    maxlevel = 10
   for c in range(1,maxlevel+1):
    webserver.addFormTextBox("Level "+str(c*10),"p505_lvl_"+str(c*10),str(self.taskdevicepluginconfig[c]),180)
    webserver.addBrowseButton("Browse","p505_lvl_"+str(c*10),startdir=str(self.taskdevicepluginconfig[c]))
   webserver.addFormNote("Specify file names/network URI for every level, that is needed!")
  return True
github enesbcs / rpieasy / _P501_USBRelay.py View on Github external
try:
   relaynum = vusb.usbrelay.getrelaynum()
  except:
   relaynum = 0
  try:
   relayids = vusb.usbrelay.getcompatibledevlist()
  except:
   relayids = []
  if relaynum&gt;0 and len(relayids)&gt;0:
   webserver.addHtml("Device ID:")
   webserver.addSelector_Head("p501_relayname",True)
   for i in range(len(relayids)):
    webserver.addSelector_Item(relayids[i][2],relayids[i][2],(relayids[i][2]==choosendev),False)
   webserver.addSelector_Foot()

   webserver.addHtml("Relay number on device:")
   webserver.addSelector_Head("p501_relaynum",True)
   for r in range(1,relaynum+1):
    webserver.addSelector_Item(r,r,(r==int(choosenrel)),False)
   webserver.addSelector_Foot()

  return True