Forgot these.
This commit is contained in:
parent
1f1676c354
commit
a46a9830ec
1
setup.py
1
setup.py
@ -41,6 +41,7 @@ setup(
|
|||||||
'hy.lex',
|
'hy.lex',
|
||||||
'hy.core',
|
'hy.core',
|
||||||
'hy.models',
|
'hy.models',
|
||||||
|
'hy.contrib',
|
||||||
],
|
],
|
||||||
author="Paul Tagliamonte",
|
author="Paul Tagliamonte",
|
||||||
author_email="tag@pault.ag",
|
author_email="tag@pault.ag",
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
|
|
||||||
; view routes
|
; view routes
|
||||||
(route "/" [] (render-template "repl.html"))
|
(route index "/" [] (render-template "repl.html"))
|
||||||
|
|
||||||
(post-route "/hy2py" []
|
(post-route hy2py "/hy2py" []
|
||||||
(try
|
(try
|
||||||
(hy-to-py (get request.form "code"))
|
(hy-to-py (get request.form "code"))
|
||||||
(catch LexException e (err "Incomplete Code."))
|
(catch LexException e (err "Incomplete Code."))
|
||||||
|
43
site/shim.py
43
site/shim.py
@ -1,46 +1,7 @@
|
|||||||
#
|
|
||||||
|
|
||||||
import hy # NOQA
|
import hy # NOQA
|
||||||
|
import hy.contrib.meth # 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")]))
|
|
||||||
|
|
||||||
|
|
||||||
from app import app
|
from app import app
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user