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:
@@ -13,12 +13,21 @@ server {
|
||||
root /usr/local/lib/web/frontend/;
|
||||
index index.html index.htm;
|
||||
|
||||
location /api/ {
|
||||
location ~ /api/ {
|
||||
try_files $uri @api;
|
||||
}
|
||||
|
||||
location ~ /resize$ {
|
||||
try_files $uri @api;
|
||||
}
|
||||
|
||||
#_RELATIVE_URL_ROOT_location /_RELATIVE_URL_ROOT_/ {
|
||||
#_RELATIVE_URL_ROOT_ rewrite /_RELATIVE_URL_ROOT_/(.*) /$1 break;
|
||||
#_RELATIVE_URL_ROOT_ root /usr/local/lib/web/frontend/;
|
||||
#_RELATIVE_URL_ROOT_}
|
||||
|
||||
location ~ /websockify$ {
|
||||
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 last;
|
||||
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
@@ -30,17 +39,12 @@ server {
|
||||
}
|
||||
|
||||
location @api {
|
||||
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 last;
|
||||
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header Host $host;
|
||||
proxy_pass http://127.0.0.1:6079;
|
||||
max_ranges 0;
|
||||
}
|
||||
|
||||
#_RELATIVE_URL_ROOT_location /_RELATIVE_URL_ROOT_/ {
|
||||
#_RELATIVE_URL_ROOT_ rewrite /_RELATIVE_URL_ROOT_/(.*) /$1 last;
|
||||
#_RELATIVE_URL_ROOT_ root /usr/local/lib/web/frontend/;
|
||||
#_RELATIVE_URL_ROOT_}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user