0

I have following codes:

<tr>
  <td>{{ q.title }}</td>                    
  <td>{{ q.text }}</td>
  <td><a href="http://localhost:8000/answer?t={{ q.title }}"> Answer </a></td>
</tr>

and in the flask I have this code:

@app.route("/answer" , methods=['GET'])
   def answer():
      atitle = request.args.get('t')
      return render_template('answer.html' , value=atitle)

I tried differend ways and also used:

@app route("/answer/<t>" , methods=['GET'])

but none of them is working and I keep recieving "GET /answer/Java HTTP/1.1" 404

1
  • are you sure your url encoding is correct? Can you print the url on console before making the request Commented Sep 11, 2018 at 20:44

1 Answer 1

0

I suspect you've got something else running on port 8000 and flask is listening on a different port (likely 5000). Try using url_for instead of constructing the url yourself...

<a href="{{ url_for('.answer', t=q.title) }}">Answer</a>

See http://flask.pocoo.org/docs/1.0/api/?highlight=url_for#flask.url_for

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.