app.py:
from flask import Flask, flash, redirect, render_template, request, url_for
app = Flask(__name__)
import requests
import json
@app.route("/", methods=['GET'])
def fill_devices():
devices = requests.request("GET", "http://10.64.127.94:5000/api/get_platforms", headers={}, data="").json()["final_result"]
return render_template('devices.html', devices=devices)
@app.route('/submit_device', methods = ['POST'])
def submit_device():
# get the device name here
labels = requests.request("GET", "http://10.64.127.94:5000/api/get_labels", headers={},
data=json.dumps(
{ "device": ""}
)).json()["final_result"]
return render_template('labels.html', labels=labels)
if __name__ == "__main__":
app.run(host='127.0.0.1', debug=True, port=5000)
labels.html
{% extends "index.html" %}
{% block devices %}
<select name="device_id">
<option>SELECT</option>
{% for device in devices %}
<option>{{ device }}</option>
{% endfor %}
</select>
{% endblock devices %}
When someone changes the value in drop down, I should get that in app.py so that I can fill the other drop down and render. How to achieve this?