1
0
mirror of https://github.com/fcwu/docker-ubuntu-vnc-desktop synced 2026-08-05 16:12:41 +02:00

feat: add resize endpoint to resize screen size (fix #115)

This commit is contained in:
Doro Wu
2019-08-19 14:07:08 +08:00
parent d4d3f867d5
commit 1affc9183a
5 changed files with 24 additions and 130 deletions
+7 -3
View File
@@ -9,7 +9,6 @@ from flask import (
Response,
jsonify,
abort,
url_for,
)
from gevent import subprocess as gsp, spawn, sleep
from geventwebsocket.exceptions import WebSocketError
@@ -28,7 +27,6 @@ app.config.from_object(os.environ.get('CONFIG') or 'config.Development')
@app.route('/api/state')
@httperror
def apistate():
print(url_for("apistate"))
state.wait(int(request.args.get('id', -1)), 30)
state.switch_video(request.args.get('video', 'false') == 'true')
mystate = state.to_dict()
@@ -40,7 +38,6 @@ def apistate():
@app.route('/api/health')
def apihealth():
print(url_for("apihealth"))
if state.health:
return 'success'
abort(503, 'unhealthy')
@@ -71,6 +68,13 @@ def reset():
return jsonify({'code': 200})
@app.route('/resize')
@httperror
def apiresize():
state.reset_size()
return '<html><head><script type = "text/javascript">var h=window.location.href;window.location.href=h.substring(0,h.length-6);</script></head></html>'
@app.route('/api/live.flv')
@httperror
def liveflv():
@@ -113,6 +113,9 @@ class State(object):
except gsp.CalledProcessError as e:
log.warn('failed to get dispaly size: ' + str(e))
def reset_size(self):
self.size_changed_count = 0
@property
def w(self):
return self._w