Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For this example we'll build a Network Status web page.  This page will be comprised of tables; the first table will summarize group status while the subsequent tables will provide node level details for each group. 

Define modules and variables

This example will utilize the following modules.

We also need to define the following variables.

  • Protocol (http or https)
  • Server
  • Username
  • Password
Code Block
#!/usr/bin/python3

import urllib.request, http.cookiejar, json

PROTOCOL = 'https'
SERVER = 'demo.opmantek.com'
USERNAME = 'nmis'

with open('/var/www/opChartsApi.conf', 'r') as confFile:
    USERPASS = confFile.read().strip()