Mam dane w pythonie , próbuję je wyswietlic w htmlu jako opcje do wyboru w select i cos nie wychodzi. Jest ktos w stanie pomoc ?
<form action="{{url_for('sensors_list')}}" method="post">
<select name="sensors" class="Input">
{% for o in data %}
<option value="{{ o.name }}">{{ o.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-10" style="height: 100px;display: flex;">
<div class="col-6" style="background-color: coral;margin-left: 0px;text-align: center;padding-top:20px;">
<a href="index.html"style="color: #ffffff;text-decoration: none;font-size:30px;"> VIBRATIONS </a>
</div>
<div class="col-6" style="background-color: crimson;text-align: center;padding-top:20px;">
<a href="setup.html"style="color: #ffffff;text-decoration: none; font-size:30px;"> SETUP </a>
</div>
</div>
</div>
<script>
fetch('/sensors')
.then(function (response) {
return response.json();
}).then(function (text) {
console.log('GET response:');
console.log(text.name);
});
</script>
@frontend_endpoints.route('/frontend/sensors_list', methods=['GET'])
def sensors_list():
'''
return json with sensor macs and aliases
Inputs:
-
Returns
return_json (JSON): JSON with columns: name, mac
'''
return_json = jsonify([{'name' : 'SENSOR 1' , 'mac' : '00:00:00:01'}, {'name' : 'SENSOR 2' , 'mac' : '00:FA:FG:03'}])
return return_json