Skip to content

Main file

The main file is a python file that uses if __name__ == "__main__" to start the server. It enables SDK capabilities such as environment variables, authentication, global hooks and importing modules.


Testing pipelines should not use the main file to start the server. For using hooks and other features consider splitting the files.

Creating the main file

It can have any name. In this example is named

from zapy import server
# (optional) setup authentication
# (optional) setup environment variables

if __name__ == "__main__":
    # only required when using GUI
        'reload': True

Over the function server.start_server() it starts a uvicorn server. This function allows uvicorn arguments such as:

  • reload (default: False) which enables debug output and auto reload.

See more uvicorn run arguments here.


The server should only be started under if __name__ == "__main__":. Otherwise, it will raise an RuntimeError: The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable.

Start server

On the top right click on offline. Under Main (optional), click on the Python icon to select the main file. Finally, click on Start server.


What happens behind

One of the following commands is executed on a VSCode terminal.

If a Main file is specified



zapy start_server