0

Hi The idea of my code is to allow the user to submit an ID through using this form

@app.route('/')
def home():
   return '''
   <form method="get">
    <textarea name="textbox"></textarea>
     <button type="submit" name="submit">Submit</button>
      </form> '''

Then the user ID is read by this route and other calculations are done

@app.route('/')
def api_id():
   text = request.form.get('textbox')
    ## Do other calculations 

My issue is that when the user inputs the ID nothing happens, only the URL changes but the calculations are not reflected.. Can you please help?

1 Answer 1

2

You need to specify the route that will receive the POST request from the form:

@app.route('/')
def home():
  return '''
   <form method="POST" action="/get_id">
    <textarea name="textbox"></textarea>
    <button type="submit" name="submit">Submit</button>
  </form> 
   '''
@app.route('/get_id', methods=['POST'])
def get_id():
  id = flask.request.form['textbox']
  #do something
Sign up to request clarification or add additional context in comments.

1 Comment

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.