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_sockets import Sockets
import waitress
import database_helper
import random
import string
......@@ -14,7 +15,8 @@ sockets = Sockets(app)
def echo_socket(ws):
while True:
message = ws.receive()
ws.send(message)
print("message : ", message)
# ws.send(message)
@app.route("/", methods = ['GET'])
def hello_world():
......@@ -232,5 +234,6 @@ def is_valid_email(email):
if __name__ == '__main__':
app.debug = True
#waitress.serve(app, host='0.0.0.0', port=5000, threads=4) #http://localhost:5000
app.run()
......@@ -23,6 +23,11 @@ window.onload = function() {
//---------------------------------------WELCOME & PROFIL---------------------------------------
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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment