Quickstart: Connect to your own Python code
The Anvil Uplink lets you connect to Python code anywhere and call Python functions directly from your app.
In this quickstart, you’ll create a simple function on your local machine and call it from your Anvil app.
Create an app
Log in to Anvil and click ‘New Blank App’. Choose the Material Design theme.

Enable the Uplink
Click the + button in the Sidebar Menu, and select Uplink:

Click the + button, then select Uplink
If you have just one deployment enviromet, you’ll be prompted to choose between a Client Uplink and a Server Uplink.
Click the Enable server Uplink button:

If you have more than one deployment enviroment, you will see the list of enviroments.
Click on the enviroment you want to connect the uplink to to selct it, and click Enable next to Server Uplink Key

This will create a secret key that you can use to connect external code to your application. Copy it to your clipboard:

Install the Uplink library
On your own computer, install the Uplink library (ensure you have Python installed).
pip install anvil-uplink
Connect a Python script to your app
Create a file called hello.py
with the following contents:
import anvil.server
anvil.server.connect("<your Uplink key>")
@anvil.server.callable
def say_hello(name):
print(f"Hello from your own machine, {name}!")
anvil.server.wait_forever()
Replace the "<your Uplink key>"
string with the Uplink key from your app.
Run the script. You should see output like this:
Connecting to wss://anvil.works/uplink
Anvil websocket open
Authenticated OK
Call your local function from your app
Back in the Anvil Editor, close the Uplink dialog and click on ‘Code’ to see the Python code for Form1
.

You will see a few lines of pre-written code. Your Form is represented as a class called Form1. It currently has
only one method, the __init__
method.

At the end of the __init__
method, write this line:
anvil.server.call('say_hello', 'Anvil Developer')
Run your app
Now click the Run button at the top right of the screen:

Go back to where your script is running. It should have printed this message:
Hello from your own machine, Anvil Developer!
You’ve successfully connected your own machine to your Anvil app.
Copy the example app
Click on the button below to clone a finished version of this app into your account.
What you can do with the Uplink
A script that runs anvil.server.connect()
can do anything an Anvil Server Module can. For example, it can:
- call functions in your Anvil Server Modules or in any other Uplink-connected script, using
anvil.server.call
- use Data Tables directly
- check which user is currently logged in
You can connect the Uplink to any environment that runs Python, including Jupyter Notebooks.
This means you are not limited to what Anvil provides — you can use all the capabilities of your own machine or setup, while still benefiting from Anvil’s features. Many people use Anvil as an add-on to their existing systems, to provide a UI or simple email client.
The Uplink works by running a Python process on your machine that connects securely to your Anvil app. Because Python can make system calls, that process can trigger any program or action your machine can perform. This makes it possible to integrate with existing systems, control hardware, run automated tests, or launch other processes directly from your Anvil app.
Next up
Want more depth on this subject?
Read more about connecting your app to any external Python code.
Want another quickstart?
Every quickstart is on the Quickstarts page.
Do you still have questions?
Our Community Forum is full of helpful information and Anvil experts.