• Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

create temporary websites

smokeshow

CI pypi license

smokeshow

Deploy ephemeral websites via HTTP or a CLI.

If you need to do any of the following:

  • 🚀 preview a site before launch
  • 🙈 view the HTML version of coverage reports
  • 👀 create a quick website to show someone something

smokeshow is here to help. It lets you create a static website, 1 year after the site is created, it vanishes like smoke in the wind.

What's great about smokeshow:

  • 💸 It's free
  • 🔑 You don't need to sign up, just create a key using the instructions below
  • 💨 It's super fast around the world, smokeshow uses CloudFlare's 280+ edge locations to store files meaning they're next to your users wherever they are

Usage Warning

smokeshow is currently free for anyone to use (within limits), but if it starts to cost me a significant amount, I might reduce the limits, or stop it being free. Please watch the github repo to get notifications of changes to the service if you're using it regularly or in an automated way.

smokeshow is open source so if you want to modify it and/or deploy your own instance to cloudflare workers, you can.

Usage

Uploading a site to smokeshow requires three steps:

  1. Create an upload key where a numeric representation of its sha-256 hash is less than 2 ^ 234. In other words; a simple proof of work. This key can then be used to create multiple sites.
  2. Create a new site.
  3. Upload one or more files to that site.

All three steps can be performed either the python CLI, or using manually.

CLI Usage

The command line interface (CLI) for smokeshow is written in python and available to download via pypi. Assuming you have python 3.7+ and pip installed, installing the smokeshow CLI should be as simple as:

pip install smokeshow

You can then get help on usage with:

smokeshow --help

To generate an upload key, use:

smokeshow generate-key

You should then set the key as an environment variable with

export SMOKESHOW_AUTH_KEY='...'

With that, you can upload a site with:

smokeshow upload path/to/upload

For more help run smokeshow upload --help, if you run smokeshow upload without either setting the SMOKESHOW_AUTH_KEY environment variable or using the --auth-key option, smokeshow will generate a new upload key before uploading the site.

If you're having trouble with python versions and accessing the CLI, you can also run the smokeshow library module as a script via

python -m smokeshow

GitHub actions & commit status integration

I build smokeshow primarily to preview documentation and coverage generate with github actions.

smokeshow therefore integrates directly with github actions to add a status to commits with a link to the newly created ephemeral site.

In addition, smokeshow has custom logic to extract the total coverage figure from coverage.py HTML coverage reports to both annotate commit status updates and decide if the commit status is "success" or "failure".

Example of setting the commit status from a github action:

- run: smokeshow upload cli/htmlcov
  env:
    SMOKESHOW_GITHUB_STATUS_DESCRIPTION: CLI Coverage {coverage-percentage}
    SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 50
    SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

(this is taken directly from smokeshow's own CI, see here)

The following environment variables are used when setting commit statuses:

  • SMOKESHOW_GITHUB_STATUS_DESCRIPTION (or alternatively the --github-status-description CLI option) set the description for the commit status; the string {coverage-percentage} has a special meaning and will be replaced by the actual coverage percentage if it can be extract from the root index.html file being uploaded, this must be set for smokeshow to set the commit status
  • SMOKESHOW_GITHUB_COVERAGE_THRESHOLD (or alternatively the --github-coverage-threshold CLI option) decide the "state" of the commit status update; success is used if either the total coverage number isn't available or it's above the threshold, failure is used if the coverage number is below this threshold
  • SMOKESHOW_GITHUB_TOKEN this is used to authenticate the status update, more details here
  • SMOKESHOW_GITHUB_PR_HEAD_SHA or if it's omitted or empty GITHUB_SHA (which is set automatically by github actions) are used to decide which commit to set the status on. The SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} trick shown above is required since github set the GITHUB_SHA env var to a merge commit on pull requests which isn't what you want
  • SMOKESHOW_GITHUB_CONTEXT suffix for github status context
  • GITHUB_REPOSITORY is set automatically by github actions, it's used to choose the repo to set the status on

Manual Usage

You can create an upload key using the following python3.6+ script:

import base64, hashlib, os

print('Searching for a key with valid hash. Hold tight, this might take a minute...')
threshold = 2 ** 234
attempts = 0
while True:
    attempts += 1
    seed = os.urandom(50)
    h = int.from_bytes(hashlib.sha256(seed).digest(), 'big')
    if attempts % 100_000 == 0:
        print('.', end='', flush=True)
    if h < threshold:
        key = base64.b64encode(seed).decode().rstrip('=')
        print(f'\nSuccess! Key found after {attempts:,} attempts:\n\n    {key}\n')
        break

(This script should take between a few seconds and a minute to generate a valid key)

Once you have your key, create a site using the following curl command:

curl -X POST \
  https://smokeshow.helpmanual.io/create/ \
  -H 'Authorisation:{generated-key-from-above}'

This should create a site and return a JSON object with details required to upload files to that site:

{
  "message": "New site created successfully",
  "secret_key": "... secret upload key ...",
  "site_creation": "2021-03-13T18:36:44.419Z",
  "site_expiration": "2021-04-12T18:36:44.419Z",
  "sites_created_24h": 0,
  "upload_expiration": "2021-03-13T19:36:44.419Z",
  "url": "https://smokeshow.helpmanual.io/... 20 char random string .../"
}

You can then upload a file, again using curl (here RESPONSE_JSON refers to the response above):

curl -X POST \
  '{RESPONSE_JSON.url}path-to-upload.html' \
  -H 'Authorisation:{RESPONSE_JSON.secret_key}' \
  -H 'Content-Type:text/html' \
  --data-binary @file-to-upload.html

Features

smokeshow doesn't have too many special features, most things are designed to be boringly predictable, But a few things warrant explanation.

Content Type

The Content-Type header in responses is not inferred by smokeshow, instead it's taken from the same header in the upload request.

Path Matches

The following path equivalence is supported:

  • /path/to/file/ should return /path/to/file/index.html or /path/to/file.html or (less canonically) /path/to/file/index.json
  • trailing slashes don't matter

Referrer Redirects

smokeshow deploys sites at a random subdirectory (e.g. /3y4x0n6a200u2n6m316j/) this works fine, but could occasionally lead to problems with sites that assume they will be deployed at root (/), we work round that problem by inspecting the Referer header and redirecting to the intended page.

Example of how this works:

  • 🔗 The page https://smokeshow.helpmanual.io/3y4x0n6a200u2n6m316j/foobar/ has a link to /another/
    which of course we want to resolve to https://smokeshow.helpmanual.io/3y4x0n6a200u2n6m316j/another/
  • 👆 When a user clicks on the link, the browser loads https://smokeshow.helpmanual.io/another/
  • 🎯 smokeshow catches this request, inspects the Referer headers and spots /3y4x0n6a200u2n6m316j/foobar/
  • 🤔 smokeshow calculates that the request should be to https://smokeshow.helpmanual.io/3y4x0n6a200u2n6m316j/another/
  • ↪️ smokeshow returns a 307 redirect to that page
  • 🏗️ the browser loads that page
  • 😊 user is happy

Limits

The following limits apply to usage of smokeshow:

  • 200: maximum number of sites you can create a day with a given key
  • 50 MB: maximum site size
  • 25 MB: maximum size of a file - this is a limit of Cloudflare's KV store

More Repositories

1

arq

Fast job queuing and RPC in python with asyncio and redis.
Python
1,989
star
2

watchfiles

Simple, modern and fast file watching and code reload in python.
Python
1,702
star
3

python-devtools

Dev tools for python
Python
921
star
4

dirty-equals

Doing dirty (but extremely useful) things with equals.
Python
776
star
5

pytest-pretty

pytest plugin for pretty printing the test summary.
Python
400
star
6

rtoml

A fast TOML library for python implemented in rust.
Python
313
star
7

JuliaByExample

Examples of Julia
Julia
296
star
8

aioaws

Asyncio compatible SDK for aws services.
Python
168
star
9

dnserver

Simple development DNS server written in python
Python
139
star
10

jinjahtml-vscode

Syntax highlighting for jinja(2) html templates in vscode
JavaScript
135
star
11

aicli

OpenAI powered AI CLI in just a few lines of code.
Python
114
star
12

buildpg

Query building for the postgresql prepared statements and asyncpg.
Python
79
star
13

nginx-pages

static site server using nginx with auto deploy via scp
Shell
67
star
14

aiohttp-vs-sanic-vs-japronto

Rough benchmarks of of aiohttp and sanic
Python
54
star
15

notbook

An argument that Jupyter Notebooks are flawed and the world needs a successor.
Python
52
star
16

pytest-speed

Modern benchmarking library for python with pytest integration.
Python
50
star
17

edge-mock

Tools for testing and developing CloudFlare worker apps.
TypeScript
50
star
18

Bokeh.jl

Bokeh Bindings for Julia
Jupyter Notebook
47
star
19

helpmanual.io

Python
43
star
20

foxglove

Python
33
star
21

xdelta3-python

Fast delta encoding in python using xdelta3
Python
30
star
22

list-python-dependencies

GitHub action to list all valid versions of dependency for a Python project
Python
29
star
23

mkdocs-run-code

TypeScript
28
star
24

nosht

Open Source Event Ticketing Platform, deployed at
Python
28
star
25

sasstastic

Fantastic SASS and SCSS compilation for python
Python
26
star
26

aiohttp-toolbox

Tools for aiohttp
Python
23
star
27

harrier

A better static site generator.
Python
21
star
28

cloudflare-proxy

proxy requests using cloudflare worker, useful for webhooks fired to slow endpoints
JavaScript
19
star
29

grablib

Static asset management in python
Python
19
star
30

cloudflare-worker-speed-test

Rust
14
star
31

edgerender

Render at the edge
TypeScript
13
star
32

coverage-badge

TypeScript
11
star
33

async-redis

Asynchronous Python redis client
Python
10
star
34

JellyFish.jl

approximate and phonetic matching of strings
Julia
10
star
35

aiohttp_runserver

Moved to
Python
10
star
36

yatl

Yet Another Template Language
TypeScript
9
star
37

django-handsontable

Django app to implement handsontable (jquery-handsontable). Uses django-rest-framework.
JavaScript
8
star
38

land-registry-price-paid-data

Land registry house price data converted to Python Pandas DataFrame
Python
8
star
39

email-forward

Docker container for email forwarding with python
Python
8
star
40

check-python-version

Check the release tag matches the library version before deploy.
Python
7
star
41

pytest-toolbox

Numerous useful plugins for pytest.
Python
7
star
42

pytest-cloudflare-worker

pytest plugin for testing cloudflare workers
Python
6
star
43

quick-strings

Rust
6
star
44

em2

Python
5
star
45

cfpypi

Private python package index using cloudflare workers
JavaScript
5
star
46

init-desktop

Python
5
star
47

donkey-make

Make for the 21st century
Rust
4
star
48

gistviewer

tool for viewing HTML file in gists
JavaScript
4
star
49

label-and-assign

GitHub action to switch labels and assignees on pull requests using comments.
Python
4
star
50

edgerender-rust

Work in progress
Rust
4
star
51

django-db-viewer

Django site for view contents of mysql, sqlite and mongdb databases and filtering the results
Python
4
star
52

password-locker

Make passwords available only when you need them (mostly for CI)
TypeScript
4
star
53

wrangler-typescript-errors

TypeScript
4
star
54

logfire_django_demo

Python
4
star
55

python-IR-demodulation

Python infrared remote control deamon.
Python
3
star
56

donkey-simple-old

Super simple site manager that provides a front end to generate static websites
Python
3
star
57

logfire-python

logfire client for python
Python
3
star
58

coverage-prepare

Convert rust coverage data to HTML reports, LCOV files or terminal tables
Rust
3
star
59

githubproxy

Proxy for GitHub that adds "Content-Type" and "Access-Control-Allow-Origin" headers.
TypeScript
3
star
60

pydantic-sandbox

me fiddling with issue templates etc for pydantic, IGNORE THIS REPO
Python
3
star
61

tensorflow-gpu-py36

Python
2
star
62

django-importexport

django app to export and import data to and from excel (and possibly other formats in the future
Python
2
star
63

keypress

press keys from the command line
Rust
2
star
64

rust-bench

some benchmarks of rust code
Rust
2
star
65

django-crud

CRUD controllers for django: Create, Retrieve, Update, Delete, List
Python
1
star
66

ci-donkey

Simple Continuous Integration system based on Django and Docker
Python
1
star
67

django-skeletal-display

django app consisting of simple display module
JavaScript
1
star
68

python-file-watcher

Python
1
star
69

csv-labels

Python
1
star
70

httpi

Rust
1
star
71

tictoc.rs

Rust
1
star
72

donkey

Like "make" but for the 21st century.
Python
1
star
73

uJSON.jl

JSON library for Julia using ultraJSON
Julia
1
star
74

testing-projects

1
star
75

TestPac.jl

Test is a demonstratoin Package, see https://github.com/samuelcolvin/julia-slideshow
Julia
1
star
76

print-debug

Python
1
star
77

bash

unofficial mirror of bash from http://savannah.gnu.org/projects/bash/
C
1
star
78

donkey-simple

Experiment
JavaScript
1
star
79

django-websockets

Experimental websocket support for django
Python
1
star
80

alpine-nginx

Docker image of stripped down nginx server using alpine. image < 15mb
Nginx
1
star
81

pdfapi

PDF API using docker
Python
1
star
82

covid-19-calcs

Jupyter Notebook
1
star
83

codeshow

very simple flask app to display just code from gists
Python
1
star
84

django-sales-estimates

Django Sales Estimates Base System
Python
1
star
85

reactstrap-toolbox

JavaScript
1
star
86

Night-Shadow

Chrome Web App: World Clock that shows an image of the world in night and day. It also displays your location and the location of your clocks.
JavaScript
1
star
87

HotDjango

Django app for displaying data - like the admin interface, but pretty and for displaying as well as editing data
Python
1
star
88

batson-perf

Rust
1
star