What I’m trying to do:
I’d like to be able to send a user on my site to be able to send a text message. So I need to pass a variable text string from the client side (from a text box that the user types into) to the server side, so that I can send it out in a text message, using the Twilio client.
What I’ve tried and what’s not working:
On the server side, I’m using a function “send_text”. That function needs to be able to pull the text string that the user enters in “text_box_1”, and send that in a text message.
It is not working because of my ignorance on how to send a value from the client side to the server side.
Code Sample:
#server side
@anvil.server.callable
def send_text():
client.messages.create(to="+12345678901",
body=(my_text),
from_="++12345678901")
#client side
def send_text_click(self, **event_args):
"""This method is called when the button is clicked"""
with anvil.server.no_loading_indicator:
self.label_1.text = anvil.server.call("send_text")
pass
Clone link: