aos-r8-webview_v2-api-json-omniswitch
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
aos-r8-webview_v2-api-json-omniswitch [2020/11/17 11:52] – benny | aos-r8-webview_v2-api-json-omniswitch [2024/06/09 10:29] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== AOS Release 8 und WebView 2.0 ====== | + | ====== AOS Release 8 und WebView 2.0 (WebGUI & API) ====== |
+ | |||
+ | In diesem Artikel werden die ersten Schritte mit dem AOS Release 8 WebView 2.0 beschrieben. | ||
===== Installation/ | ===== Installation/ | ||
Zeile 67: | Zeile 69: | ||
</ | </ | ||
+ | <WRAP center round tip 60%> | ||
+ | Ein Neustart ist nicht notwendig! Der Zugriff ist nun via WebGUI möglich (siehe folgender Screenshot), | ||
+ | </ | ||
+ | |||
+ | {{ :: | ||
< | < | ||
Zeile 94: | Zeile 101: | ||
Router-> | Router-> | ||
</ | </ | ||
+ | |||
+ | ===== Verwendung der WebView 2.0 API ===== | ||
+ | |||
+ | ==== API: Login und Ausgabe der Systemfunktionen ==== | ||
+ | |||
+ | === Ausgabe in der CMD-Box/ | ||
+ | |||
+ | < | ||
+ | % python3 print_capabilities.py | ||
+ | OS6465T-P12 | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Quellcode für das obige Beispiel === | ||
+ | |||
+ | <file python print_capabilities.py> | ||
+ | # | ||
+ | |||
+ | import sys | ||
+ | try: | ||
+ | import requests | ||
+ | except ImportError as ie: | ||
+ | print(ie) | ||
+ | sys.exit(" | ||
+ | import urllib3 | ||
+ | import json | ||
+ | from mysecrets import mysecrets | ||
+ | |||
+ | # Modify the mysecrets.py | ||
+ | fqdn = mysecrets[" | ||
+ | username = mysecrets[" | ||
+ | password = mysecrets[" | ||
+ | validate_https_certificate = mysecrets[" | ||
+ | # This will not work directly, as the params have to be urlencoded | ||
+ | #login_url = " | ||
+ | omniswitch_url = " | ||
+ | |||
+ | login_params = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | |||
+ | req_headers = { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | |||
+ | if(validate_https_certificate.lower() == " | ||
+ | check_certs = True | ||
+ | else: | ||
+ | # This is needed to get rid of a warning coming from urllib3 on self-signed certificates | ||
+ | # print(" | ||
+ | # print(" | ||
+ | urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||
+ | check_certs = False | ||
+ | |||
+ | # req will also hold a session cookie for all following interactions | ||
+ | req = requests.Session() | ||
+ | |||
+ | # Login and obtain cookie for session | ||
+ | resp = req.get(omniswitch_url, | ||
+ | if resp.status_code == 200: | ||
+ | # resp.json() will contain something like {' | ||
+ | if resp.json()[" | ||
+ | sys.exit(resp.json()[" | ||
+ | elif resp.json()[" | ||
+ | pass | ||
+ | else: | ||
+ | sys.exit(" | ||
+ | |||
+ | getwebview_params = { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | |||
+ | resp = req.get(omniswitch_url, | ||
+ | if resp.status_code == 200: | ||
+ | # resp.json() will contain something like {' | ||
+ | if resp.json()[" | ||
+ | sys.exit(resp.json()[" | ||
+ | elif resp.json()[" | ||
+ | for k, v in resp.json()[" | ||
+ | if isinstance(v, | ||
+ | print(v) | ||
+ | elif isinstance(v, | ||
+ | print(json.dumps(v, | ||
+ | else: | ||
+ | sys.exit(" | ||
+ | </ | ||
+ | |||
+ | <file python mysecrets.py> | ||
+ | mysecrets = { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Weitere Beispiele auf GitHub ==== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ |
aos-r8-webview_v2-api-json-omniswitch.1605613934.txt.gz · Zuletzt geändert: 2024/06/09 10:29 (Externe Bearbeitung)