Skip to main content

No project description provided

Project description

tinyhost

Have you ever wanted to host a webpage? Me too!

Except no one wants to host their own server these days. Too much trouble keeping that thing secure, updated, properly firewalled. It's overkill for hosting just a tiny simple page.

You could just upload a static page to S3, but for a backend you'd need to add serverless product like AWS Lambda functions. But even then you would need some place to store your data...

Introducing, serverless-less web hosting with tinyhost

Installation instructions:

pip install tinyhost

Host your first page, with a simple backend:

tinyhost examples/checkbox.html

Then share the provided link with your trusted friends and coworkers!

tinyhost will put your static page on S3, and provide it with a simple backend, also hosted on S3! It's literally S3 all the way down.

How it works

tinyhost adds two Javascript functions to your page before it gets uploaded to cloud storage:

/**
 * Fetches the state from an S3-backed datastore using a presigned GET URL.
 *
 * @async
 * @function fetchDatastore
 * @returns {Promise<Object|null>} The JSON data from the datastore, or null if there was an error.
 */
async function fetchDatastore();

/**
 * Uploads data to an automatically configured S3-backed datastore using a presigned POST URL and fields.
 *
 * @async
 * @function putDatastore
 * @param {Object} data - The single Object to be written to the datastore as JSON
 * @returns {Promise<void>} Resolves if the data is successfully uploaded, or logs an error if the upload fails.
 */
async function putDatastore(data);

You can use these two functions in your code to save and retrieve a single Javascript Object (serialized via JSON).

Your datastore is stored in your S3 bucket right next to your webpage, and we internally create a presigned URL so that your page can read/write to it securely. All of this is automatically added to your HTML so you don't even need to think about it.

The link to your site, and your datastore will work for 1 week. But don't worry, after that, the data is still saved, you can just run tinyhost again on the same file to get a fresh link.

Security

tinyhost is meant for sharing tiny websites and prototypes with trusted friends and coworkers. Anyone with a link to your page can see your site, and write anything they want to your page's datastore.

Datastores are limited to a max of 2MB, and no other permissions in your S3 account are ever granted. You also don't need to make your S3 bucket public, and in fact no permissions are ever altered on any objects.

Advanced Usage

Usage: tinyhost [OPTIONS] HTML_FILE

  Hosts your html_file on an S3 bucket, and gives back a signed URL. Can also host Jupyter notebooks.
  
  Assumes that you have AWS credentials in your environment. Run `aws
  configure` if not.

  If you don't pass in an S3 bucket, the script will prompt you to create one,
  if it's possible. Otherwise, it will use the specified bucket

Options:
  --bucket TEXT       S3 bucket on which to host your static site
  --prefix TEXT       S3 bucket prefix to use
  --reset             Reset the data store back to an empty object
  --duration INTEGER  Length of time in seconds that this resulting link will
                      work for. Default is 1 week. Max is also 1 week.
  --help              Show this message and exit.

Valid AWS Credentials must be in your environment. If they are not already, run

aws configure

If a bucket is not specified, one will be automatically created as s3://[username]-tinyhost

Motivation

Internally at AI2, we use tinyhost to share little websites automatically generated by other AI tools. For example, you may be training a neural network classifier, and you want to ask your team to help tag a little bit of data.

  1. Ask ChatGPT or Claude to load your training set and output a simple webpage that contains 20 examples via Jinja2 template.

  2. Host the resulting page with tinyhost.

  3. Get feedback and quickly iterate on your ideas.

It's useful even without the datastore as a quick way to share a pretty HTML page, without worrying about having to clean up cloud resources later.

Team

tinyhost is developed and maintained by the AllenNLP team, backed by the Allen Institute for Artificial Intelligence (AI2). AI2 is a non-profit institute with the mission to contribute to humanity through high-impact AI research and engineering. To learn more about who specifically contributed to this codebase, see our contributors page.

License

tinyhost is licensed under Apache 2.0. A full copy of the license can be found on GitHub.

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

tinyhost-0.4.16.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

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

tinyhost-0.4.16-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file tinyhost-0.4.16.tar.gz.

File metadata

  • Download URL: tinyhost-0.4.16.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for tinyhost-0.4.16.tar.gz
Algorithm Hash digest
SHA256 c5dfec88f4d6099cf97dc14de1c54a0ae010edae53f1148332df03eff2e104b3
MD5 07c9cc46cc23b14a36a095b37af6d3a1
BLAKE2b-256 85a14c4564c20c3568c9e1009ff9bc0df0322b602f59387995b58fee3ff8b434

See more details on using hashes here.

File details

Details for the file tinyhost-0.4.16-py3-none-any.whl.

File metadata

  • Download URL: tinyhost-0.4.16-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for tinyhost-0.4.16-py3-none-any.whl
Algorithm Hash digest
SHA256 e23b154dd695052b3a4ef65e3e040e0c0b562e1139260f2e5bee17c7d141ebe3
MD5 a388851ddec12652c9e34a6cd460e409
BLAKE2b-256 41201688a8bd6891570a4d92d957a7cca19ed240fe60b67abb699c35c400b31e

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