mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 14:24:40 -07:00
Fixed flask issues with connection
This commit is contained in:
parent
53fc0f48c8
commit
3e8401be22
3 changed files with 14 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
from pathlib import Path
|
||||
|
||||
from flask import Flask, send_file, Response, render_template, render_template_string, request, g
|
||||
from flask_socketio import SocketIO
|
||||
from flask_socketio import SocketIO, emit
|
||||
|
||||
|
||||
def create_flask_app(s2c, c2s, s2flask, args):
|
||||
|
@ -71,9 +71,15 @@ def create_flask_app(s2c, c2s, s2flask, args):
|
|||
return send_file(preview_file, mimetype='image/jpeg', cache_timeout=-1)
|
||||
|
||||
socketio = SocketIO(app)
|
||||
@socketio.on('connect')
|
||||
def connect():
|
||||
pass
|
||||
|
||||
@socketio.on('connect', namespace='/')
|
||||
def test_connect():
|
||||
emit('my response', {'data': 'Connected'})
|
||||
|
||||
@socketio.on('disconnect', namespace='/test')
|
||||
def test_disconnect():
|
||||
print('Client disconnected')
|
||||
|
||||
return socketio, app
|
||||
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
$.post("{{ url_for('change_history_range') }}");
|
||||
});
|
||||
|
||||
const socket = io.connect('127.0.0.1:5000');
|
||||
socket.on('preview', function() {
|
||||
console.log('new preview!');
|
||||
const socket = io.connect('http://' + document.domain + ':' + location.port);
|
||||
socket.on('preview', function(msg) {
|
||||
console.log(new Date(), '- new preview -', msg);
|
||||
$('img#preview').attr("src", "{{ url_for('preview_image') }}?q=" + new Date().getTime());
|
||||
});
|
||||
});
|
||||
|
|
|
@ -366,7 +366,7 @@ def main(args, device_args):
|
|||
preview_file = str(model_path / filename)
|
||||
cv2.imwrite(preview_file, preview_pane_image)
|
||||
s2flask.put({'op': 'show'})
|
||||
socketio.emit('preview', {})
|
||||
socketio.emit('preview', {'iter': iteration, 'loss': loss_history[-1]})
|
||||
|
||||
# cv2.imshow(wnd_name, preview_pane_image)
|
||||
is_showing = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue