muhaha
This commit is contained in:
parent
37d134b32b
commit
b9e621fa07
28
demo/app.py
Normal file
28
demo/app.py
Normal file
@ -0,0 +1,28 @@
|
||||
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)
|
2
demo/static/jquery-1.8.3.min.js
vendored
Normal file
2
demo/static/jquery-1.8.3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
demo/static/jquery.min.js
vendored
Symbolic link
1
demo/static/jquery.min.js
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
jquery-1.8.3.min.js
|
48
demo/templates/index.html
Normal file
48
demo/templates/index.html
Normal file
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Hy!</title>
|
||||
<script type="text/javascript" src="/static/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#repl-input").keyup(function(e) {
|
||||
var input = $("#repl-input").val();
|
||||
console.log("Input: " + input);
|
||||
$('#repl-output').load(
|
||||
'/translate',
|
||||
{"code": input}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
html, body {
|
||||
height: 90%;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
.repl {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#repl-input {
|
||||
float: left;
|
||||
width: 49%;
|
||||
border: 0px solid #000000;
|
||||
resize: none;
|
||||
height: 100%;
|
||||
}
|
||||
#repl-output {
|
||||
float: right;
|
||||
width: 49%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class = 'repl' >
|
||||
<textarea id = 'repl-input' >; LISP input</textarea>
|
||||
<pre id = 'repl-output' ></pre>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user