diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2017-10-11 19:39:04 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2017-10-11 19:39:56 -0400 |
| commit | 49fda3601248d939b0cfff1bff5a18800e498bdc (patch) | |
| tree | de97903cdb154a9ba11d8d2b603c2b90c45aa8a0 /app.py | |
The HTML is kind of jank
Diffstat (limited to 'app.py')
| -rw-r--r-- | app.py | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +from apistar import Include, Route, annotate, render_template +from apistar.frameworks.wsgi import WSGIApp as App +from apistar.handlers import docs_urls, static_urls +from apistar.renderers import HTMLRenderer +import random +import yaml + +with open('things-to-check.yml', 'r') as things_file: + things = yaml.safe_load(things_file) + +@annotate(renderers=[HTMLRenderer()]) +def random_thing(item: int = None): + if item is None: + item = random.randrange(len(things)) + return render_template('index.html', + item=item, + thing=things[item], + ) + + +routes = [ + Route('/', 'GET', random_thing), + Include('/docs', docs_urls), + Include('/static', static_urls), +] + +settings = { + 'TEMPLATES': { + 'ROOT_DIR': 'templates', # Include the 'templates/' directory. + 'PACKAGE_DIRS': ['apistar'] # Include the built-in apistar templates. + } +} + +app = App( + routes=routes, + settings=settings, +) |
