-
Notifications
You must be signed in to change notification settings - Fork 1
/
listener.py
29 lines (25 loc) · 975 Bytes
/
listener.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
from flask import Flask, jsonify
from flask import request
import subprocess,os
app=Flask(__name__)
SHARE_FOLDER_WINDOWS = "D:/VMUbuntu/Share"
SHARE_FOLDER_LINUX = "/mnt/hgfs/Share"
@app.route("/vscode", methods=["POST"])
def vscode():
if request.method == "POST":
if request.content_type.startswith('application/json'):
addr = request.json.get('addr')
line = request.json.get('line')
elif request.content_type.startswith('multipart/form-data'):
addr = request.form.get('addr')
line = request.form.get('line')
else:
addr = request.values.get("addr")
line = request.values.get('line')
addr = addr.replace(SHARE_FOLDER_LINUX,SHARE_FOLDER_WINDOWS)
subprocess.Popen('Code.exe -g "%s":%s'%(addr,line))
return "success"
else:
return "method error"
if __name__=="__main__":
app.run(port=4567,host="192.168.65.1",debug=True)