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.
Install latest from the GitHub repository:
$ pip install git+https://github.com/AnswerDotAI/plash-cli.git
or from pypi
$ pip install plash-cli
To use Plash, you’ll need to authenticate:
- Signup for an account at https://pla.sh/
- Activate your Plash subscription
- Run
plash_login
in your terminal - A browser window will open for authentication
- Once authenticated, your credentials will be saved locally
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
Run plash_deploy
. Your app will be live at
https://<app-name>.pla.sh
. The URL will be shown in the deployment
output.
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
If your app needs additional dependencies to run, we offer a number of ways to have them included in your deployed app.
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.
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>
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.
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.
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.