-1

I have a from with three possible inputs to submit and send through a seperate script that then generates JSON data.

The problem is however while two inputs are actual inputs = one email and one being a nummer. The third one is not a really traditional input.

<form  action="{ url_for('handle_data') }}" method="POST">
    <div class="form-group">
        <label for="Speryear">SPER jaar</label>
        <input class="form-control" type="number" value="2" name="Speryear" min=0 max=10 />
    </div>
    <div class="form-group">
        <div class="form-group">
            <label for="inputEmail">Verzendings mail</label>
            <input class="form-control" type="email" name="inputEmail" required />
        </div>
    </div>
    <div class="form-group">
        <div class="url-panel">
            <p> <b>Url:</b></p>
            <p id="api-url" name="api-url"></p>
        </div>
    </div>
    <button id="search" type="submit" class="btn-primary">
    Aanvraag indienen</button>
</form>


@app.route('/handle_data', methods=['POST'])
def handle_data():
    sper_year = request.form["Speryear"]
    email = request.form["inputEmail"]
    url = request.form["api-url"]
    Requested_data = GIPOD_converter.main(url, sper_year, email)
return Requested_data

The third input is actually a paragraph which is dynamically based on the values of a second form (the primary from) for the data requests. According to this post here: Sending data from a html non-input to Flask

HTML forms only send along tagged values to the remote endpoint when a "submit" input is pressed.

I have tried to make this paragraph a data input but the thing is this will break the javascript I have for that specific id. Aka a the URL part that I want cannot be generated in the input field. So can my code get the paragraph from this?

Edits done as per answer.

2
  • have you thought of encoding it to Base64(in JS) and then decoding it in flask? Commented Apr 21, 2021 at 23:26
  • Uh sorry kind of an amateur of this. I am now trying to solve this in Javascript. By getting the value of the paragraph and putting that into a input box. Commented Apr 21, 2021 at 23:30

1 Answer 1

0

I think you should end the app route with:

return Requested_data

Also, you do not define correctly to the url form, i.e.:

url = request.form["api-url"]
Sign up to request clarification or add additional context in comments.

4 Comments

Yeah I know this is still being under construction but I will ad the suggestion in as, my main question still remains though can I still get the data aka the url variable from this paragraph?
Also added in a edit thank you but I was still writing it. Again the question remains? Wil it take the paragraph is an input for the variable.
No it wont. I think you should take care of that part with javascript. :)
Oh man. And my current Javascript will not work on setting that input, it will only work on paragraph with id = #api-url...oh wait facepalm. document.getElementById("api-url").value = url.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.