Skip to content

Commit 3bd579a

Browse files
authored
Merge pull request #42 from apiad/feature/fastapi
Feature/fastapi
2 parents 7021f90 + 145183f commit 3bd579a

File tree

8 files changed

+114
-14
lines changed

8 files changed

+114
-14
lines changed

README.md renamed to Readme.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
[<img alt="Travis (.org)" src="https://img.shields.io/travis/apiad/auditorium/master.svg">](https://travis-ci.org/apiad/auditorium)
77
[<img alt="Codecov" src="https://img.shields.io/codecov/c/github/apiad/auditorium.svg">](https://codecov.io/gh/apiad/auditorium)
88
[<img alt="Gitter" src="https://img.shields.io/gitter/room/apiad/auditorium">](https://gitter.im/auditorium-slides/community)
9-
[<img alt="Demo" src="https://img.shields.io/badge/demo-browse-blueviolet"></img>](https://auditorium-demo.now.sh)
9+
[<img alt="Demo" src="https://img.shields.io/badge/demo-browse-blueviolet"></img>](https://auditorium-demo.apiad.net)
1010

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

1515
## What's this about
1616

@@ -242,12 +242,34 @@ However, beware when hosting presentations online.
242242
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.
243243
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.
244244

245+
## Made with Auditorium
246+
247+
* [Auditorium Demo](https://auditorium-demo.apiad.net) - a slideshow showcasing the most important features from `auditorium`.
248+
249+
### Your Contributions Here
250+
251+
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.
252+
253+
If you feel like sending some support please consider adding a badge somewhere in your website or repository:
254+
255+
```html
256+
<a href="https://apiad.net/auditorium"><img alt="Made with Auditorium" src="https://img.shields.io/badge/made--with-auditorium-blue"></img></a>
257+
```
258+
259+
It looks like this:
260+
261+
<a href="https://apiad.net/auditorium"><img alt="Made with Auditorium" src="https://img.shields.io/badge/made--with-auditorium-blue"></img></a>
262+
245263
## History
246264

265+
### v19.1.1
266+
267+
* To celebrate the new year we are switching to [calver](https://calver.org/) versioning for good!
268+
247269
### v0.6.5
248270

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

252274
### v0.6.4
253275

auditorium/demo.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,16 @@ def pyplot(ctx):
342342
Dynamically generated graphs with `pyplot` can be added
343343
also very easily.
344344
"""
345-
from matplotlib import pyplot as plt
346-
import numpy as np
345+
346+
try:
347+
from matplotlib import pyplot as plt
348+
import numpy as np
349+
except ImportError:
350+
with ctx.error("Dependencies missing"):
351+
ctx.markdown("You need `matplotlib` installed to make this slide work. Make sure to run:")
352+
353+
ctx.code("pip install matplotlib", "bash")
354+
return
347355

348356
xg = np.random.RandomState(0)
349357
yg = np.random.RandomState(1)

demo/Readme.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Auditorium
2+
3+
[<img alt="PyPI - License" src="https://img.shields.io/pypi/l/auditorium.svg">](https://github.com/apiad/auditorium/blob/master/LICENSE)
4+
[<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/auditorium.svg">](https://pypi.org/project/auditorium/)
5+
[<img alt="PyPI" src="https://img.shields.io/pypi/v/auditorium.svg">](https://pypi.org/project/auditorium/)
6+
[<img alt="Travis (.org)" src="https://img.shields.io/travis/apiad/auditorium/master.svg">](https://travis-ci.org/apiad/auditorium)
7+
[<img alt="Codecov" src="https://img.shields.io/codecov/c/github/apiad/auditorium.svg">](https://codecov.io/gh/apiad/auditorium)
8+
[<img alt="Gitter" src="https://img.shields.io/gitter/room/apiad/auditorium">](https://gitter.im/auditorium-slides/community)
9+
[<img alt="Demo" src="https://img.shields.io/badge/demo-browse-blueviolet"></img>](https://auditorium-demo.apiad.net)
10+
11+
> A Python-powered slideshow creator with steroids.
12+
13+
See the demo at [auditorium-demo.apiad.net](https://auditorium-demo.apiad.net).
14+
15+
## Hosting a slideshow at `now.sh`
16+
17+
[<img alt="Made with Auditorium" src="https://img.shields.io/badge/made--with-auditorium-blue"></img>](https://apiad.net/auditorium)
18+
19+
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.
20+
21+
In short, these are the basic steps:
22+
23+
1. Make sure your `slideshow.py` (or whatever the name) slideshow file has the following line:
24+
25+
```python
26+
from auditorium import Show
27+
28+
show = Show("My Awesome Show")
29+
app = show.app # <--- This line
30+
```
31+
32+
This will allow `now.sh` serverless functions to find your slideshow's underlying `sanic` application, and automagically make the backend logic work.
33+
34+
2. Make a folder for uploading to `now.sh`, let's call it `my-show` and an `api` folder inside.
35+
36+
```bash
37+
mkdir -p /path/to/my-show/api
38+
```
39+
40+
3. Render the HTML.
41+
42+
```bash
43+
auditorium render /path/to/slideshow.py > /path/to/my-show/index.html
44+
```
45+
46+
4. Have your `slideshow.py` copied to `my-show/api/update.py`
47+
48+
```bash
49+
cp /path/to/slideshow.py /path/to/my-show/api/update.py
50+
```
51+
52+
5. Add a `now.json` file with an adequate configuration. This one works for the demo (replace `name` with your name):
53+
54+
```json
55+
{
56+
"name": "auditorium-demo",
57+
"rewrites": [
58+
{ "source": "/", "destination": "/index.html" },
59+
{ "source": "/update", "destination": "/api/update" }
60+
]
61+
}
62+
```
63+
64+
6. Add a `requirements.txt` file with your requirements. This one works for the demo:
65+
66+
```ini
67+
auditorium==0.6.5 # This is basically mandatory :)
68+
matplotlib==3.1.2 # Stuff you use in your slides
69+
```
70+
71+
7. [Install](https://zeit.co/docs#install-now-cli) and run `now` inside the `my-show` folder.

demo/api/demo.py renamed to demo/api/update.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,6 @@ def append(ctx):
465465
ctx.code("show.append('auditorium/static/md/demo.md')")
466466

467467

468-
# from auditorium.markdown import load_markdown_demo
468+
from auditorium.markdown import load_markdown_demo
469469

470-
# show.append(load_markdown_demo())
470+
show.append(load_markdown_demo())
File renamed without changes.

demo/now.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "auditorium-demo",
33
"rewrites": [
4-
{ "source": "/", "destination": "/demo.html" },
5-
{ "source": "/update", "destination": "/api/demo" }
4+
{ "source": "/", "destination": "/index.html" },
5+
{ "source": "/update", "destination": "/api/update" }
66
]
77
}

demo/requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
auditorium==0.6.4
2-
sanic==19.9.0
1+
auditorium==0.6.5
32
matplotlib==3.1.2

pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[tool.poetry]
22
name = "auditorium"
3-
version = "0.6.5"
3+
version = "19.1.1"
44
description = "A Python-powered slideshow maker with steroids."
55
authors = ["Alejandro Piad <[email protected]>"]
66
license = "MIT"
7-
readme = "README.md"
7+
readme = "Readme.md"
88

99
[tool.poetry.dependencies]
1010
python = "^3.6"
@@ -24,7 +24,7 @@ mkdocs = "^1.0.4"
2424

2525
[tool.poetry.scripts]
2626
auditorium = "auditorium.__main__:main"
27+
2728
[build-system]
2829
requires = ["poetry>=0.12"]
2930
build-backend = "poetry.masonry.api"
30-

0 commit comments

Comments
 (0)