#๐Ÿ”’ Calling function in script from an HTML (JInja+Flask) page

4 messages ยท Page 1 of 1 (latest)

real hill
#

I am trying to create a VERY basic webpage whose entire purpose is to hold buttons. When those buttons are pressed, I need it to send a message to the backend/server/main script with the same text as the button.
For example, I have a list with a bunch of names, I use jinja templates to create a button for each name. When that button is pushed, I need that name to be sent to the backend. The list will change, so I can't do static pages for each one.

This is my first attempt, the buttons are created, but I cannot figure out how to send the action back

incentivesInteractive = []
# # # Flask 

app = Flask(__name__)

@app.route("/", methods=['GET', 'POST'])
def main():
    if request.method == 'POST':
        print('test')
    return render_template('control.html',items=incentives)```
red tartanBOT
#

@real hill

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

red tartanBOT
#

@real hill

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.