sudoers nopasswd freeIPAгугл выдал решение
document.getElementById("myForm").addEventListener('submit', (event) => {
const data = new FormData(event.target);
if(!formValid(data)) {
event.preventDefault(); // отменяем action формы
return;
}
})
document.getElementById("myForm").addEventListener('submit', (event) => {
const data = new FormData(event.target);
fetch("/register", {
method: 'POST',
body: data
})
.then((response) => response.json())
.then((data) => {
// тут рисуешь алерты в DOM
})
.catch((error) => {
console.log(`fetch.post response came up with an error: ${error}`);
});
event.preventDefault();
})
if request.method == 'POST':
data = request.form
ok, err = validateForm(data)
if not ok:
return jsonify(err)
DoRegisterUser(data)
return redirect(url_for(index))
GET /guest/s/default/?id=be:ef:00:df:dd:ee&ap=78:78:78:78:78:78&t=1500000000&url=http://captive.apple.com%2fhotspot-detect.html&ssid=blabla HTTP/1.0
from pyunifi.controller import Controller
c = Controller(UNIFI_WLC_IP, UNIFI_WLC_USER, UNIFI_WLC_PASSW, UNIFI_WLC_PORT, INIFI_WLC_VER, UNIFI_WLC_SITE_ID, UNIFI_WLC_SSL_VERIFY)
c.authorize_guest(mac, TIME_QOUTE,
up_bandwidth=None, down_bandwidth=None, byte_quota=None, ap_mac=None)
result = ssh.send_command('show run')
with open(f"{device_name}.cfg") as f:
f.write(result)
if cur.fetchone() is None:
<div>
<button id="jsfetch">fetch json</button>
</div>
document.querySelector("#jsfetch").addEventListener("click", Handler);
function Handler(event) {
fetch('/api')
.then((response) => {
return response.json();
})
.then((myjson) => {
console.log(myjson);
});
}
from flask import jsonify
data = {
"id": 123,
"name": "Вася",
"surname": "Пупкин"
}
@app.route('/api')
def api():
return jsonify(data)
Object { id: 123, name: "Вася", surname: "Пупкин" }
In [1]: import yaml
In [2]: ymlsample="""
...: branch1:
...: name: branch1
...: ip: 1.2.3.4
...: ASN: 65101
...: type: cisco
...: auth:
...: username: username
...: password: password
...: branch2:
...: name: branch2
...: ip: 2.3.4.5
...: ASN: 65102
...: type: juniper
...: auth:
...: username: username
...: password: password
...: """
In [3]: hosts = yaml.safe_load(ymlsample)
In [4]: hosts
Out[4]:
{'branch1': {'name': 'branch1',
'ip': '1.2.3.4',
'ASN': 65101,
'type': 'cisco',
'auth': {'username': 'username', 'password': 'password'}},
'branch2': {'name': 'branch2',
'ip': '2.3.4.5',
'ASN': 65102,
'type': 'juniper',
'auth': {'username': 'username', 'password': 'password'}}}