diff --git a/setup.py b/setup.py index 60be10f..7fac3f3 100755 --- a/setup.py +++ b/setup.py @@ -41,6 +41,7 @@ setup( 'hy.lex', 'hy.core', 'hy.models', + 'hy.contrib', ], author="Paul Tagliamonte", author_email="tag@pault.ag", diff --git a/site/app.hy b/site/app.hy index f1fbe47..9d5a623 100644 --- a/site/app.hy +++ b/site/app.hy @@ -23,9 +23,9 @@ ; view routes -(route "/" [] (render-template "repl.html")) +(route index "/" [] (render-template "repl.html")) -(post-route "/hy2py" [] +(post-route hy2py "/hy2py" [] (try (hy-to-py (get request.form "code")) (catch LexException e (err "Incomplete Code.")) diff --git a/site/shim.py b/site/shim.py index be23481..119d9a6 100644 --- a/site/shim.py +++ b/site/shim.py @@ -1,46 +1,7 @@ -# - import hy # NOQA - -from hy.models.expression import HyExpression -from hy.models.symbol import HySymbol -from hy.models.string import HyString -from hy.models.list import HyList -from hy.models.dict import HyDict - -from hy.macros import macro - - -def router(tree, rkwargs=None): - tree.pop(0) - path = tree.pop(0) - tree.insert(0, HySymbol("fn")) - - route = HyExpression([HySymbol(".route"), - HySymbol("app"), - path]) - - if rkwargs: - route = HyExpression([HySymbol("kwapply"), - route, - HyDict({HyString("methods"): rkwargs})]) - - return HyExpression([HySymbol("decorate_with"), - route, - tree]) - - -@macro("route") -def route_macro(tree): - return router(tree) - - -@macro("post_route") -def post_route_macro(tree): - return router(tree, rkwargs=HyList([HyString("POST")])) - - +import hy.contrib.meth # NOQA from app import app + if __name__ == '__main__': app.run(debug=True)