Skip to content

Commit

Permalink
Merge pull request #42 from apiad/feature/fastapi
Browse files Browse the repository at this point in the history
Feature/fastapi
  • Loading branch information
apiad authored Jan 1, 2020
2 parents 7021f90 + 145183f commit 3bd579a
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 14 deletions.
28 changes: 25 additions & 3 deletions README.md → Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
[<img alt="Travis (.org)" src="https://img.shields.io/travis/apiad/auditorium/master.svg">](https://travis-ci.org/apiad/auditorium)
[<img alt="Codecov" src="https://img.shields.io/codecov/c/github/apiad/auditorium.svg">](https://codecov.io/gh/apiad/auditorium)
[<img alt="Gitter" src="https://img.shields.io/gitter/room/apiad/auditorium">](https://gitter.im/auditorium-slides/community)
[<img alt="Demo" src="https://img.shields.io/badge/demo-browse-blueviolet"></img>](https://auditorium-demo.now.sh)
[<img alt="Demo" src="https://img.shields.io/badge/demo-browse-blueviolet"></img>](https://auditorium-demo.apiad.net)

> A Python-powered slideshow creator with steroids.
See the demo at [auditorium-demo.now.sh](https://auditorium-demo.now.sh).
See the demo at [auditorium-demo.apiad.net](https://auditorium-demo.apiad.net).

## What's this about

Expand Down Expand Up @@ -242,12 +242,34 @@ However, beware when hosting presentations online.
Since the backend code runs in your computer, a viewer could inject nasty stuff such as importing `os` and deleting your home folder! In the future I might add a `--safe` option that only allows for animations and other interactive behaviors that don't use input directly from the user.
Staying away from `eval` and `exec` should keep you safe in most scenarios, but the basic suggestion is don't do anything you wouldn't do in a regular web application, since all security issues are the same.

## Made with Auditorium

* [Auditorium Demo](https://auditorium-demo.apiad.net) - a slideshow showcasing the most important features from `auditorium`.

### Your Contributions Here

If you have a slideshow to showcase here, feel free to [edit this Readme](https://github.com/apiad/auditorium/edit/master/README.md) and send a pull request. Add your website, Github repository, and any other information.

If you feel like sending some support please consider adding a badge somewhere in your website or repository:

```html
<a href="https://apiad.net/auditorium"><img alt="Made with Auditorium" src="https://img.shields.io/badge/made--with-auditorium-blue"></img></a>
```

It looks like this:

<a href="https://apiad.net/auditorium"><img alt="Made with Auditorium" src="https://img.shields.io/badge/made--with-auditorium-blue"></img></a>

## History

### v19.1.1

* To celebrate the new year we are switching to [calver](https://calver.org/) versioning for good!

### v0.6.5

* Improved compatibility for [Now](https://now.sh) static deployments.
* The demo has now been moved to [auditorium-demo.now.sh](https://auditorium-demo.now.sh).
* The demo has now been moved to [auditorium-demo.apiad.net](https://auditorium-demo.apiad.net).

### v0.6.4

Expand Down
12 changes: 10 additions & 2 deletions auditorium/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,16 @@ def pyplot(ctx):
Dynamically generated graphs with `pyplot` can be added
also very easily.
"""
from matplotlib import pyplot as plt
import numpy as np

try:
from matplotlib import pyplot as plt
import numpy as np
except ImportError:
with ctx.error("Dependencies missing"):
ctx.markdown("You need `matplotlib` installed to make this slide work. Make sure to run:")

ctx.code("pip install matplotlib", "bash")
return

xg = np.random.RandomState(0)
yg = np.random.RandomState(1)
Expand Down
71 changes: 71 additions & 0 deletions demo/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Auditorium

[<img alt="PyPI - License" src="https://img.shields.io/pypi/l/auditorium.svg">](https://github.com/apiad/auditorium/blob/master/LICENSE)
[<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/auditorium.svg">](https://pypi.org/project/auditorium/)
[<img alt="PyPI" src="https://img.shields.io/pypi/v/auditorium.svg">](https://pypi.org/project/auditorium/)
[<img alt="Travis (.org)" src="https://img.shields.io/travis/apiad/auditorium/master.svg">](https://travis-ci.org/apiad/auditorium)
[<img alt="Codecov" src="https://img.shields.io/codecov/c/github/apiad/auditorium.svg">](https://codecov.io/gh/apiad/auditorium)
[<img alt="Gitter" src="https://img.shields.io/gitter/room/apiad/auditorium">](https://gitter.im/auditorium-slides/community)
[<img alt="Demo" src="https://img.shields.io/badge/demo-browse-blueviolet"></img>](https://auditorium-demo.apiad.net)

> A Python-powered slideshow creator with steroids.
See the demo at [auditorium-demo.apiad.net](https://auditorium-demo.apiad.net).

## Hosting a slideshow at `now.sh`

[<img alt="Made with Auditorium" src="https://img.shields.io/badge/made--with-auditorium-blue"></img>](https://apiad.net/auditorium)

This folder shows the layout you need to comply with for hosting a slideshow at [now.sh](https://now.sh), such that the backend logic works as well. If you don't know what [now.sh](https://now.sh) is, go and [read about it](https://zeit.co/docs) first.

In short, these are the basic steps:

1. Make sure your `slideshow.py` (or whatever the name) slideshow file has the following line:

```python
from auditorium import Show

show = Show("My Awesome Show")
app = show.app # <--- This line
```

This will allow `now.sh` serverless functions to find your slideshow's underlying `sanic` application, and automagically make the backend logic work.

2. Make a folder for uploading to `now.sh`, let's call it `my-show` and an `api` folder inside.

```bash
mkdir -p /path/to/my-show/api
```

3. Render the HTML.

```bash
auditorium render /path/to/slideshow.py > /path/to/my-show/index.html
```

4. Have your `slideshow.py` copied to `my-show/api/update.py`

```bash
cp /path/to/slideshow.py /path/to/my-show/api/update.py
```

5. Add a `now.json` file with an adequate configuration. This one works for the demo (replace `name` with your name):

```json
{
"name": "auditorium-demo",
"rewrites": [
{ "source": "/", "destination": "/index.html" },
{ "source": "/update", "destination": "/api/update" }
]
}
```

6. Add a `requirements.txt` file with your requirements. This one works for the demo:

```ini
auditorium==0.6.5 # This is basically mandatory :)
matplotlib==3.1.2 # Stuff you use in your slides
```

7. [Install](https://zeit.co/docs#install-now-cli) and run `now` inside the `my-show` folder.
4 changes: 2 additions & 2 deletions demo/api/demo.py → demo/api/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,6 @@ def append(ctx):
ctx.code("show.append('auditorium/static/md/demo.md')")


# from auditorium.markdown import load_markdown_demo
from auditorium.markdown import load_markdown_demo

# show.append(load_markdown_demo())
show.append(load_markdown_demo())
File renamed without changes.
4 changes: 2 additions & 2 deletions demo/now.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "auditorium-demo",
"rewrites": [
{ "source": "/", "destination": "/demo.html" },
{ "source": "/update", "destination": "/api/demo" }
{ "source": "/", "destination": "/index.html" },
{ "source": "/update", "destination": "/api/update" }
]
}
3 changes: 1 addition & 2 deletions demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
auditorium==0.6.4
sanic==19.9.0
auditorium==0.6.5
matplotlib==3.1.2
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tool.poetry]
name = "auditorium"
version = "0.6.5"
version = "19.1.1"
description = "A Python-powered slideshow maker with steroids."
authors = ["Alejandro Piad <[email protected]>"]
license = "MIT"
readme = "README.md"
readme = "Readme.md"

[tool.poetry.dependencies]
python = "^3.6"
Expand All @@ -24,7 +24,7 @@ mkdocs = "^1.0.4"

[tool.poetry.scripts]
auditorium = "auditorium.__main__:main"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

0 comments on commit 3bd579a

Please sign in to comment.