quickcap

A minimalist Python library to deploy apps to CapRover

quickcap is a Python library for deploying python apps to a VPS in just a few lines of code. It wraps CapRover to handle Docker deployment, subdomains, and HTTPS with sensible defaults.

You can deploy an app on its dedicated subdomain in few lines of code

# create the app
setup_app(caprover_server, token, app_name)

# deploy the app
deploy(caprover_server, token, app_name, "myapp.py", requirements)
# app is deployed on https://app_name.subdomain.tld
{'status': 100, 'description': 'Deploy is done', 'data': {}}

Installation

pip install quickcap

Usage

Login

import os

caprover_server = os.environ.get("CAPROVER_SERVER") 
caprover_password =os.environ.get("CAPROVER_PASSWORD") 

token = caplogin(caprover_server, caprover_password)

Create a webapp

First, create your app in a Python file:

example_app = """from fasthtml.common import *

app = FastHTML()

@app.route("/")
def home(): return Div(H1("Hello World!"), P("Deployed with CapRover API"))

serve()
"""

from pathlib import Path 
_ = Path("myapp.py").write_text(example_app)

Setup and deploy

Create the app on CapRover with SSL and optional configuration:

app_name = "myapp"

setup_app(caprover_server, token, app_name, env_vars={"MY_SECRET": "supersecret123"})
{'status': 100, 'description': 'Updated App Definition Saved', 'data': {}}

Deploy your script:

# requirements: python package used by your app
requirements = ["python-fasthtml"]

deploy(caprover_server, token, app_name, "myapp.py", requirements)
{'status': 100, 'description': 'Deploy is done', 'data': {}}

Your app is now live at https://myapp.yourdomain.com!

Check logs

Runtime logs:

logs = get_app_logs(caprover_server, token, app_name)

Delete an app

delete_app(caprover_server, token, app_name)
{'status': 100, 'description': 'App is deleted', 'data': {}}

API Reference

Function Description
caplogin Login and get authentication token
setup_app Create app with SSL and configuration (recommended)
deploy Build and deploy FastHTML app from script(s)
get_app_logs Get runtime logs
get_app_deployment_logs Get build logs
delete_app Remove an app
create_app Register a new app (low-level)
update_app Update app configuration (low-level)
enable_ssl Enable HTTPS for an app (low-level)
upload_app Upload tar.gz archive (low-level)