forked from DenerosArmy/pythonscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
36 lines (29 loc) · 882 Bytes
/
server.py
File metadata and controls
36 lines (29 loc) · 882 Bytes
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, request,jsonify
import ast
from notebook import convert
from functools import wraps
from flask import Flask,url_for,render_template
import json
import logging
app = Flask(__name__)
app.debug = True
from flask import make_response
from functools import update_wrapper
def nocache(f):
def new_func(*args, **kwargs):
resp = make_response(f(*args, **kwargs))
resp.cache_control.no_cache = True
return resp
return update_wrapper(new_func, f)
@nocache
@app.route("/api", methods=['GET', 'POST'])
def hello():
t = ast.parse(str(request.args['code']))
output = str(convert(t))
return jsonify(r=output)
#return str(request.args['callback'] + "({0})".format(output[:-2]))
@app.route("/", methods=['GET', 'POST'])
def test():
return render_template('index.html')
if __name__ == "__main__":
app.run()