Dear Anvil,
I am new to Anvil, trying to follow the tutorial of using uplink from my own laptop. However I spent hours still can’t get a simple hello world example working
My client side code simply a button
from ._anvil_designer import Form1Template
from anvil import *
import anvil.server
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
def button_1_click(self, **event_args):
"""This method is called when the button is clicked"""
anvil.server.call("say_hello", 'Hey')
alert('Got it')
My server side code basically copied from the pop up window after click uplink.
import anvil.server
anvil.server.connect("<my uplink key>")
@anvil.server.callable
def say_hello(name):
print("Hello from the uplink, %s!" % name)
anvil.server.wait_forever()
When runs the above script, I got messages:
Connecting to wss://anvil.works/uplink
Anvil websocket open
Connected to "Default environment" as SERVER
When run the app, and click the button, I got
AppOfflineError: Connection to server failed (error)
at Form1, line 15
Seems not connected to my laptop.
Please help, many thanks!