hy/demo/app.py
Paul Tagliamonte 3a708add3b things
2012-12-30 19:35:30 -05:00

29 lines
563 B
Python

from hy.compiler.ast27 import forge_ast
from hy.lex.tokenize import tokenize
import codegen
import sys
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/translate', methods=['POST'])
def translate():
lines = request.form['code']
try:
code = tokenize(lines)
ast = forge_ast("stdin", code)
return codegen.to_source(ast)
except Exception as e:
return str(e)
if __name__ == '__main__':
app.run(debug=True)