Friday 30 March 2018

json - Post an array of objects from an HTML form using Flask?

I want to generate this JSON object containing an array of objects from form inputs:



{
"network":[
{"layer_type": "conv2d", "num_filters": 16, "kernel_size": 2, "padding": "valid", "stride": 2},
{"layer_type": "max_pool2d", "num_filters": 16, "kernel_size": 2, "padding": "valid", "stride": 2},
{"layer_type": "conv2d", "num_filters": 32, "kernel_size": 3, "padding": "valid", "stride": 2}
]
}



Is there a way I can do this using Flask?



Update



Here's what the form looks like:



form with array of objects




As for the snippet of html code dynamically generated:
















  • Edit: Since this question is being marked as duplicate I'm going to add more info. I want to achieve something like this in this question but using Flask:



    {"students" => [
    {
    "first" => "foo",
    "last" => "bar",

    "age" => "21"
    },
    {
    "first" => "baz",
    "last" => "qux",
    "age" => "19"
    }
    ]}



    It does work with Ruby according to the accepted answer there by having this kind of form:















    But I want to know how to do it using Flask.

    No comments:

    Post a Comment

    casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

    In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...