Skip to main content

Huggingface deployment for FastHTML

Project description

FastHTML on 🤗 Spaces

Deploy a FastHTML application to Hugging Face Spaces for free with one command!

Quickstart

  1. Create a free account on Hugging Face
  2. Go to your account settings and create an access token with write access. Keep this token safe and don't share it.
  3. Set the HF_TOKEN environment variable to that token
  4. Install fasthtml-hf: pip install fasthtml-hf
  5. HuggingFace needs fasthtml-hf to run your space, so add it to your requirements.txt file.
  6. At the top of your main.py add from fasthtml_hf import setup_hf_backup, and just before you run uvicorn add setup_hf_backup(app). If you run uvicorn in an if __name__ == "__main__" block, you'll need to call setup_hf_backup(app) before the if block.
  7. Run fh_hf_deploy <space_name>, replacing <space_name> with the name you want to give your space.

By default this will upload a public space. You can make it private with --private true.

Configuration

The space will upload a backup of your database to a Hugging Face Dataset. By default it will be private and its name will be <your-huggingface-id>/space-backup. You can change this behavior in the config.ini file. In not provided, a default file will be created with the contents (note that the [DEFAULT] line is required at the top):

[DEFAULT]
dataset_id = space-backup
db_dir = data
private_backup = True
interval = 15 # number of minutes between periodic backups

If you so choose, you can disable the automatic backups and use persistent storage instead for $5/month (USD).

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

fasthtml_hf-0.1.5.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

fasthtml_hf-0.1.5-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file fasthtml_hf-0.1.5.tar.gz.

File metadata

  • Download URL: fasthtml_hf-0.1.5.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for fasthtml_hf-0.1.5.tar.gz
Algorithm Hash digest
SHA256 7a687e77c1b330a4410cf7c18864bf82753e97d45b69b7ce89d97b6c2245b2e6
MD5 5d914ae820b1076d36583f88edd6769b
BLAKE2b-256 91fb145dca8d6e5c9b9b64b66065a91c6105d9091a2e6ebdc63f492a8fcdbddf

See more details on using hashes here.

File details

Details for the file fasthtml_hf-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: fasthtml_hf-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for fasthtml_hf-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 219200564cc51ee07499e0634e86fe1363f48068f10d6f859edcc404f15a8851
MD5 50b945e24f2312365927f0f2ee242b52
BLAKE2b-256 20f5a6e6883c3978c3c45d460ebdab387b46484c3861038afe472b16ef7c5813

See more details on using hashes here.

Supported by

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