I have designed a basic REST API with flask and Python 3 to restart services on a locked down application. Using Postman, I would send a HTTP POST with anapplication/json body similar to;
{
"fqdn" : ["my-fqdn-1.domain.com", "my-fqdn-2.domain.com"],
"control_type" : "Start",
"service" : ["Service 1", "Service 2"]
}
Sometimes, fqdn may be just 1 entry, other times, it could be 10. The same goes for service, sometime I might want to stop 1 service, other times stop 5. So far everything is working fine but now I would like to create a HTML form to provide similar functionality. On the form, I was thinking of having 1 row for fqdn, 1 row for service and then a dropdown for control_type. I could then dynamically add more rows for fqdn and service using Javascript similar to this Stackoverflow question.
What I am trying to figure out is how I would convert for example HTML inputs (not real HTML, just example)<name=Service1>Service1</> <name=Service2>Service2</> <name=Service3>Service4</> back to a Python List. For single values, it is easy;
fqdn = request.form["fqdn"]
service = request.form["service"]
but if I don't know how many rows to expect, I can't figure out how to process it.
control_type.fqdnandservicecould be different for different users hence I was thinking the only way would be input.