https://github.com/pyx/hyer
Hyer - Hy enhanced routing
https://github.com/pyx/hyer
flask hy macros
Last synced: about 1 year ago
JSON representation
Hyer - Hy enhanced routing
- Host: GitHub
- URL: https://github.com/pyx/hyer
- Owner: pyx
- License: other
- Created: 2015-02-27T04:46:29.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-10-21T10:52:51.000Z (over 9 years ago)
- Last Synced: 2025-04-05T19:02:22.468Z (about 1 year ago)
- Topics: flask, hy, macros
- Language: Hy
- Size: 27.3 KB
- Stars: 17
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
==========================
Hyer - Hy enhanced routing
==========================
Introduction
============
Hyer is a collection of `Hy `_ macros
for `flask `_
*Okay, show me some code*
From :code:`examples/hello/app.hy`
.. code:: hy
(require hyer.dsl)
(defn create-app []
"application factory"
(defapplication app []
(GET index "/"
"Hello world")
(GET greeting "//"
(.format "Hello, {}!" username))
(GET addition "/+/"
(.format "{} + {} = {}" a b (+ a b)))))
(defmain [&rest args]
(-> create-app apply .run))
This is the same code in pure python:
.. code:: python
from flask import Flask
def create_app():
"""application factory"""
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello world'
@app.route('//')
def greeting(username):
return 'Hello, {}!'.format(username)
@app.route('/+/')
def addition(a, b):
return '{} + {} = {}'.format(a, b, a + b)
return app
if __name__ == '__main__':
create_app().run()
Requirements
============
- CPython >= 2.7
- flask
- hy >= 0.10.1
Installation
============
Install from PyPI::
pip install hyer
In source directory, run::
make install
License
=======
BSD New, see LICENSE for details.
Links
=====
Documentation:
http://hyer.readthedocs.org/
Issue Tracker:
https://bitbucket.org/pyx/hyer/issues/
Source Package @ PyPI:
https://pypi.python.org/pypi/hyer/
Mercurial Repository @ bitbucket:
https://bitbucket.org/pyx/hyer/
Git Repository @ Github:
https://github.com/pyx/hyer/