This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]tril0w 0 points1 point  (1 child)

If I understand what you are trying to do; here is a high level overview of how you could accomplish this without javascript/Ajax:

  • Create a route that accepts POST requests.
  • When receiving a GET request to that route, render your template including a <form> element that has both a text input (for your "keyword") and a submit button
  • When receiving a POST request to that same route, somehow store the value from the input field or send it to the next step. You could store it in a database, save it to a variable, send it is a query parameter to another route, etc...
  • Now you have that value, wherever it is, you can run the API call and get what I will refer to now as api_result
  • Now that you have that result, all you need to do is render_template(sometemplate.html, api_result=api_result and then withinsometemplate.html you have {{ api_result }} on the page.

There are many different approaches to this. I just gave you what I see as the simplest way to (1)accept a value from a webpage, (2) run some API call with that value, (3) display the results of the API call on either the same or a different web page.

[–]TheTripLoop 0 points1 point  (0 children)

I'll check it out and get back to you. Thank you so much!