...
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.
- urllib.request - https://docs.python.org/3/library/urllib.request.html
- http.cookiejar - https://docs.python.org/3/library/http.cookiejar.html
- json - https://docs.python.org/3/library/json.html
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() |