Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pyx/hyer

Hyer - Hy enhanced routing
https://github.com/pyx/hyer

flask hy macros

Last synced: about 1 month ago
JSON representation

Hyer - Hy enhanced routing

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/