hy/demo/app.py
Paul Tagliamonte 6455fe951a uneeded sys
2013-01-21 12:19:35 -05:00

28 lines
552 B
Python

from hy.compiler.ast27 import forge_ast
from hy.lex.tokenize import tokenize
import codegen
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)