-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (42 loc) · 871 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from flask import Flask, render_template, send_file
from flask_socketio import SocketIO, emit
from flask_cors import CORS
import time
app = Flask(__name__)
CORS(app)
socket = SocketIO(app)
@app.route("/")
def handle():
return render_template(
'index.html',
title = "page 2",
userName = "maxence",
table = ["max","toto","henry"],
)
@app.route("/templates/<path:path>")
def handleGetFile(path : str):
return send_file(f"templates/{path}")
@socket.on("connect")
def handleConnect():
print("in socket connect")
emit(
"data",
{
"data": "salut"
}
)
@socket.on("data")
def handleData(mess=None):
print("in socket data")
emit(
"data",
{
"data": "salut"
}
)
socket.run(
app,
host='localhost',
port=5000,
debug=True
)