-
Notifications
You must be signed in to change notification settings - Fork 31
/
app.py
35 lines (28 loc) · 1010 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from flask import Flask
from flask import request
from flask import jsonify
from flask import send_file
from parse import make_ast
app = Flask(__name__, static_folder='front/build/static')
@app.route('/')
def index():
return send_file('front/build/index.html')
@app.route('/favicon.ico')
def favicon_ico():
return send_file('front/build/favicon.png')
@app.route('/api/_parse', methods=['POST'])
def api_parse():
body = request.get_data()
try:
return jsonify({ 'ast': make_ast(body) })
except Exception as e:
return jsonify({ 'ast': { 'error': 'yes', 'why_error?': 'it doesn\'t compile, yo' }})
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
return response
if __name__ == "__main__":
app.debug = True
app.run('0.0.0.0', 4361)