zack commited on
Commit
1022169
1 Parent(s): 1808c39

🔧 Update app dependencies

Browse files
Files changed (1) hide show
  1. backend/app.py +26 -16
backend/app.py CHANGED
@@ -6,6 +6,7 @@ import argparse
6
  # import asyncio
7
  # from multiprocessing import Process
8
  import gradio as gr
 
9
 
10
  app = Flask(__name__)
11
  CORS(app)
@@ -64,7 +65,31 @@ def Root():
64
  # return jsonify({"executed" : True,
65
  # "process" : "ended" })
66
 
67
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  @app.route("/api/append/port" , methods=["POST"])
70
  def append_port():
@@ -85,16 +110,6 @@ def remove_port():
85
  return jsonify({"executed" : True,
86
  "ports" : current['port']})
87
 
88
-
89
- # @app.route("/api/remove/module" , methods=["POST"])
90
- # def remove_module():
91
- # current = request.json
92
-
93
- # visable.remove(current)
94
- # process_map[current["kwargs"]["metadata"]].terminate()
95
- # return jsonify({"executed" : True,
96
- # "ports" : current['port']})
97
-
98
  @app.route("/api/open/ports", methods=["GET"])
99
  def open_ports():
100
  return jsonify(visable)
@@ -106,8 +121,3 @@ if __name__ == "__main__":
106
  parser.add_argument("-p", "--port", help="location of flask api port on local host", default=5000)
107
  args = parser.parse_args()
108
  app.run(host="0.0.0.0", port=args.port, debug=True)
109
-
110
-
111
-
112
-
113
-
 
6
  # import asyncio
7
  # from multiprocessing import Process
8
  import gradio as gr
9
+ from proxmoxer import ProxmoxAPI
10
 
11
  app = Flask(__name__)
12
  CORS(app)
 
65
  # return jsonify({"executed" : True,
66
  # "process" : "ended" })
67
 
68
+ @app.route("/api/preview_vnc", methods=["POST"])
69
+ def preview_vnc():
70
+ data = request.json
71
+ vmid = data['vmID']
72
+ nodeid = data['nodeid']
73
+ proxmox = ProxmoxAPI('proxmox-domain', user='api', password='password', verify_ssl=False)
74
+ config = proxmox.nodes(nodeid).qemu(vmid).vncproxy.create(websocket=1)
75
+ ticket = proxmox.access.ticket.post(username='api', password='password')['data']['ticket']
76
+ port = config['data']['port']
77
+ host = 'proxmox-domain'
78
+ src_href = f'https://{host}:8006/?console=kvm&novnc=1&node={nodeid}&resize=1&vmid={vmid}&path=api2/json/nodes/{nodeid}/qemu/{vmid}/vncwebsocket/port/{port}/vncticket/{ticket}'
79
+ return jsonify({"iframe_src": src_href})
80
+
81
+ @app.route("/api/proxmox/vnc", methods=["POST"])
82
+ def create_proxmox_vnc():
83
+ data = request.json
84
+ vmid = data['vmid']
85
+ node = data['node']
86
+ proxmox = ProxmoxAPI('proxmox-domain', user='user@pam', password='password', verify_ssl=False)
87
+ config = proxmox.nodes(node).qemu(vmid).vncproxy.create(websocket=1)
88
+ ticket = proxmox.access.ticket.post(username='user@pam', password='password')['data']['ticket']
89
+ port = config['data']['port']
90
+ host = 'proxmox-domain'
91
+ src_href = f'https://{host}:8006/?console=kvm&novnc=1&node={node}&resize=1&vmid={vmid}&path=api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket/port/{port}/vncticket/{ticket}'
92
+ return jsonify({"iframe_src": src_href})
93
 
94
  @app.route("/api/append/port" , methods=["POST"])
95
  def append_port():
 
110
  return jsonify({"executed" : True,
111
  "ports" : current['port']})
112
 
 
 
 
 
 
 
 
 
 
 
113
  @app.route("/api/open/ports", methods=["GET"])
114
  def open_ports():
115
  return jsonify(visable)
 
121
  parser.add_argument("-p", "--port", help="location of flask api port on local host", default=5000)
122
  args = parser.parse_args()
123
  app.run(host="0.0.0.0", port=args.port, debug=True)