Skip to content
Snippets Groups Projects
Commit b8360664 authored by ComeF2's avatar ComeF2
Browse files

Tentative implémentation step 3 (Fonctionne pas)

parent 3a2543d2
No related branches found
No related tags found
No related merge requests found
File added
No preview for this file type
No preview for this file type
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
from flask_sockets import Sockets from flask_sockets import Sockets
import waitress
import database_helper import database_helper
import random import random
import string import string
...@@ -14,7 +15,8 @@ sockets = Sockets(app) ...@@ -14,7 +15,8 @@ sockets = Sockets(app)
def echo_socket(ws): def echo_socket(ws):
while True: while True:
message = ws.receive() message = ws.receive()
ws.send(message) print("message : ", message)
# ws.send(message)
@app.route("/", methods = ['GET']) @app.route("/", methods = ['GET'])
def hello_world(): def hello_world():
...@@ -232,5 +234,6 @@ def is_valid_email(email): ...@@ -232,5 +234,6 @@ def is_valid_email(email):
if __name__ == '__main__': if __name__ == '__main__':
app.debug = True app.debug = True
#waitress.serve(app, host='0.0.0.0', port=5000, threads=4) #http://localhost:5000
app.run() app.run()
...@@ -23,6 +23,11 @@ window.onload = function() { ...@@ -23,6 +23,11 @@ window.onload = function() {
//---------------------------------------WELCOME & PROFIL--------------------------------------- //---------------------------------------WELCOME & PROFIL---------------------------------------
function displayWelcomeView() { function displayWelcomeView() {
var ws = new WebSocket("ws://localhost:5000/echo")
ws.onopen = function(event) {
console.log("Connexion WebSocket établie !");
ws.send("Hello, server!");
};
document.getElementById("displaywelcome").innerHTML = document.getElementById("welcomeview").innerHTML; document.getElementById("displaywelcome").innerHTML = document.getElementById("welcomeview").innerHTML;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment