Skip to content

pyx/hyer

Repository files navigation

Hyer - Hy enhanced routing

Introduction

Hyer is a collection of Hy macros for flask

Okay, show me some code

From examples/hello/app.hy

(require hyer.dsl)

(defn create-app []
  "application factory"
  (defapplication app []
    (GET index "/"
      "Hello world")
    (GET greeting "/<username>/"
      (.format "Hello, {}!" username))
    (GET addition "/<int:a>+<int:b>/"
      (.format "{} + {} = {}" a b (+ a b)))))

(defmain [&rest args]
  (-> create-app apply .run))

This is the same code in pure python:

from flask import Flask

def create_app():
    """application factory"""
    app = Flask(__name__)

    @app.route('/')
    def index():
        return 'Hello world'

    @app.route('/<username>/')
    def greeting(username):
        return 'Hello, {}!'.format(username)

    @app.route('/<int:a>+<int:b>/')
    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/

About

Hyer - Hy enhanced routing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published