CLI for the Plash hosting service
Project description
plash-cli
WARNING - Plash is in Beta and we have released it in its semi-stable state to gather early feedback to improve. We do not recommend hosting critical applications yet.
Usage
Installation
Install latest from the GitHub repository:
$ pip install git+https://github.com/AnswerDotAI/plash-cli.git
or from pypi
$ pip install plash_cli
Deploy Your First FastHTML App
Authentication
To use Plash, you’ll need to authenticate:
- Signup for an account at https://pla.sh/
- Activate your Plash subscription
- Run
plash_loginin your terminal - A browser window will open for authentication
- Once authenticated, your credentials will be saved locally
Create a FastHTML App
Create a directory for your FastHTML app, and go into it:
mkdir minimal
cd minimal
Create main.py containing:
from fasthtml.common import *
app, rt = fast_app()
@rt
def index():
return H1("Hello world!")
serve()
Then create a requirements.txt containing:
python-fasthtml
Deploy your app
Run plash_deploy. Your app will be live at
https://<app-name>.pla.sh. The URL will be shown in the deployment
output.
Managing Your App
Plash CLI provides several commands to manage your apps:
plash_login- Login to Plashplash_deploy- Deploy your appplash_view- Open your deployed app in a browserplash_start- Start your app if it’s stoppedplash_stop- Stop your running appplash_logs- View your app’s logsplash_download- Download your deployed app filesplash_delete- Delete your deployed app
App Dependencies
If your app needs additional dependencies to run, we offer a number of ways to have them included in your deployed app.
Python Dependencies
To have python dependencies installed in your deployed app, you can
provide a requirements.txt and it will be pip installed. By default,
all deployed apps have fasthtml as a dependency.
Non-Python Dependencies
For any other depencies of setup processes, you can provide a setup.sh
which will be executed during the build step of your app. For example,
you can use this to install apt packages (this is ran as root in your
apps container, so omit any sudo):
#!/bin/bash
apt install <package_name>
Env Variables
If your app depends on secrets or other types of environment variables,
you can have them available in your deployed app by providing a
plash.env, which will be sourced during your apps startup. Here is an
example:
export MY_ENV_VARIABLE=hijkl
export ANOTHER_SECRET=abcdef
Inside of your running container, we automatically set an environment
variable (PLASH_PRODUCTION=1) so you are able to use it for checking
if your application is inside a Plash deployment or not.
Databases
For apps that use persistent storage, we recommend sqlite. The docker
container your app runs in has a working directory of /app which is a
volume mounted to a folder that we hourly backup. Therefore, we
recommend placing your sqlite database somewhere in that directory. Note
when redeploying an app with plash_deploy, we automatically overwrite
existing files with the same name as those uploaded. Therefore to
prevent data loss, ensure any local database files do not clash with any
deployed database names that your app may set up. You can use the
environment variable PLASH_PRODUCTION, which we automatically set to 1
in your Plash container, to modify your apps behavior for local and
production development. You can download any deployed database names by
clicking the Download App button to get a compressed file of all files
in your /app folder in your deployed app.
Deploy to Pla.sh via GitHub Actions
If you’d like to deploy your plash app every time you commit changes to
your GitHub repo, you can use the following workflow to your
.github/workflows/ folder in the root of your repo:
name: Deploy to Plash
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Create Plash config
run: |
mkdir -p ~/.config
echo '${{ secrets.PLASH_CONFIG }}' > ~/.config/plash_config.json
- name: Install plash-cli with pip
run: pip install plash-cli
- name: Deploy to Plash
run: plash_deploy
It relies on storing your plash config as a secret named PLASH_CONFIG
in your GitHub repo. After running plash_login, you can find these in
~/.config/plash_config.json (unless you haved changed the
XDG_CONFIG_HOME environment variable). Learn more about GitHub secrets
here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plash_cli-0.0.5.tar.gz.
File metadata
- Download URL: plash_cli-0.0.5.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62c08553ffa92732642333dd585abbbfb2e25ebab69f9f8e6d42b731d8ec629b
|
|
| MD5 |
3c064a07e059ac555ecd720567066ce2
|
|
| BLAKE2b-256 |
77e23d87103332e60af506d74dda5dbef5d84068e22b04bc71cbfbe145894e4c
|
File details
Details for the file plash_cli-0.0.5-py3-none-any.whl.
File metadata
- Download URL: plash_cli-0.0.5-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc560ad49a400af627d9f54a5be01b2371f269afebc7ec078d3d0683e178d155
|
|
| MD5 |
1287e16b0a4c8cb9420561bbb02934a1
|
|
| BLAKE2b-256 |
cb42e057808f333d26d408aa86b6d7c3c2a904db63519f03abd4f9fc006d99e7
|