Skip to main content

CLI for the Plash hosting service

Project description

plash-cli

Deploy your FastHTML apps in seconds. Fast, reliable, and effortless hosting for developers who want to focus on building, not deploying.

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 from pypi:

$ pip install plash-cli

Or install latest from the GitHub repository:

$ pip install git+https://github.com/AnswerDotAI/plash-cli.git

Deploy Your First FastHTML App

Authentication

To use Plash, you’ll need to authenticate:

  1. Signup for an account at https://pla.sh/
  2. Activate your Plash subscription
  3. Run plash_login in your terminal
  4. A browser window will open for authentication
  5. 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

In the terminal 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 Plash
  • plash_deploy - Deploy your app
  • plash_view - Open your deployed app in a browser
  • plash_start - Start your app if it’s stopped
  • plash_stop - Stop your running app
  • plash_logs - View your app’s logs
  • plash_download - Download your deployed app files
  • plash_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

Python dependencies can be provided in one of two ways:

  1. a requirements.txt file (example)
  2. a main.py file with inline dependencies according to PEP723 (example)

Please note:

  • Always include python-fasthtml as a dependency
  • Declare dependencies using exactly one of the above ways, not both

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plash_cli-0.1.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plash_cli-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file plash_cli-0.1.0.tar.gz.

File metadata

  • Download URL: plash_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for plash_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99a33ee0dd8c3fa11d185ee86f0dc4d95b91aa44f7146bc2dfcddb4a8f6b8569
MD5 9af92c007746e3a9dd0180c4be6b3497
BLAKE2b-256 b2b9eb3ffaa1a8207136e79a06643ae09e002975a3a03852e822e7ff93adc025

See more details on using hashes here.

File details

Details for the file plash_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: plash_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for plash_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9b212032ed333ebcf0e24913c2c644778b0171d0e34c6b91b50245eddfaf0c2
MD5 e26a114a87cad0490b26e9a329d4b3c3
BLAKE2b-256 eec816dddc7d41e755066c3b418b99590d2828f10d7df5e6458ef8c819bba546

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page