Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

Uplink: Code outside Anvil

Sometimes you want to write some server-side code that can’t run on our servers. Perhaps it needs resources that are only available on your company network, or on your computer.

You can connect code anywhere on the Internet to your Anvil app using the Anvil Uplink.

The Uplink makes any Python code behave like a Server Module: you can call functions in it from your app using anvil.server.call. The connection goes both ways; you can anvil.server.call into your app from the Uplink.

Anything you can do in a Server Module can also be done from the Uplink - using app_tables to search and modify your Data Tables, or using anvil.users.get_user() to check who’s logged in, for example.

It’s common to use the Uplink to connect to a Jupyter Notebook to create an Anvil front-end for your Data Science models. Here’s a tutorial video where we do just that.

Here’s a script that you can run on your own machine and connect to your app.

import anvil.server

anvil.server.connect("<your Uplink key>")

@anvil.server.callable
def get_data(name):
  print("Hello from your own machine, %s!" % name)
  return [1, 2, 4, 8]

anvil.server.wait_forever()

To run this, you need to pip install anvil-uplink and enable the Uplink in the Anvil Editor - see Setting Up for complete instructions.