# quickcap


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

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

``` python
# 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

``` python
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:

``` python
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:

``` python
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:

``` python
# 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:

``` python
logs = get_app_logs(caprover_server, token, app_name)
```

### Delete an app

``` python
delete_app(caprover_server, token, app_name)
```

    {'status': 100, 'description': 'App is deleted', 'data': {}}

# API Reference

<table>
<colgroup>
<col style="width: 43%" />
<col style="width: 56%" />
</colgroup>
<thead>
<tr>
<th>Function</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#caplogin"><code>caplogin</code></a></td>
<td>Login and get authentication token</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#setup_app"><code>setup_app</code></a></td>
<td>Create app with SSL and configuration (recommended)</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#deploy"><code>deploy</code></a></td>
<td>Build and deploy FastHTML app from script(s)</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#get_app_logs"><code>get_app_logs</code></a></td>
<td>Get runtime logs</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#get_app_deployment_logs"><code>get_app_deployment_logs</code></a></td>
<td>Get build logs</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#delete_app"><code>delete_app</code></a></td>
<td>Remove an app</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#create_app"><code>create_app</code></a></td>
<td>Register a new app (low-level)</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#update_app"><code>update_app</code></a></td>
<td>Update app configuration (low-level)</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#enable_ssl"><code>enable_ssl</code></a></td>
<td>Enable HTTPS for an app (low-level)</td>
</tr>
<tr>
<td><a
href="https://tchambon.github.io/quickcap/core.html#upload_app"><code>upload_app</code></a></td>
<td>Upload tar.gz archive (low-level)</td>
</tr>
</tbody>
</table>
