Skip to content

Commit 102d111

Browse files
authored
Create PyServer.py
1 parent 2a42216 commit 102d111

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

bin/PyServer.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# PyServer 1.0 - PyWimVBA 6.0
2+
from flask import Flask,request
3+
app = Flask(__name__)
4+
from io import StringIO
5+
from contextlib import redirect_stdout
6+
from traceback import format_exc
7+
import sys
8+
value = {}
9+
@app.route("/")
10+
def main():
11+
if request.args.get("code") == None:
12+
return "PyWimVBA server, this does nothing"
13+
elif request.args.get("code") == "$clear":
14+
sys.modules[__name__].__dict__.clear()
15+
return "Cleared"
16+
else:
17+
cpde = request.args.get("code")
18+
f = StringIO()
19+
cpde = cpde.replace(";;","\n")
20+
with redirect_stdout(f):
21+
try:
22+
exec(cpde, globals())
23+
except:
24+
te = format_exc()
25+
return te.replace("\n",";;")
26+
s = f.getvalue()
27+
return s
28+
if __name__ == "__main__":
29+
app.run(debug=True,host="0.0.0.0",port="9812")

0 commit comments

Comments
 (0)