-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding websocket to flask with SocketIO
- Loading branch information
Showing
8 changed files
with
63 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
services: | ||
db: | ||
image: postgres:15.2 | ||
image: postgres:16.1 | ||
container_name: db | ||
env_file: | ||
- .env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import sockets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from flask_socketio import emit, send | ||
from app import socketio | ||
|
||
@socketio.on('message') | ||
def handle_message(message): | ||
print('Received message:', message) | ||
emit('response', {'data': 'Server received your message'}) | ||
|
||
@socketio.on('json') | ||
def handle_json(json): | ||
print('received json: ' + str(json)) | ||
|
||
@socketio.on('my event') | ||
def handle_my_custom_event(json): | ||
print('received my_event: ' + str(json)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
bidict==0.22.1 | ||
click==8.1.7 | ||
dnspython==2.4.2 | ||
eventlet==0.34.2 | ||
Flask==2.2.3 | ||
Flask-Cors==3.0.10 | ||
Flask-SocketIO==5.3.6 | ||
Flask-SQLAlchemy==3.0.3 | ||
greenlet==2.0.2 | ||
gunicorn==21.2.0 | ||
h11==0.14.0 | ||
importlib-metadata==7.0.1 | ||
itsdangerous==2.1.2 | ||
Jinja2==3.1.2 | ||
MarkupSafe==2.1.3 | ||
packaging==23.2 | ||
psycopg2-binary==2.9.6 | ||
python-engineio==4.8.2 | ||
python-socketio==5.11.0 | ||
simple-websocket==1.0.0 | ||
six==1.16.0 | ||
SQLAlchemy==2.0.9 | ||
typing_extensions==4.9.0 | ||
Werkzeug==2.2.3 | ||
wsproto==1.2.0 | ||
zipp==3.15.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ server { | |
proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Forwarded-Prefix /; | ||
} | ||
} | ||
} |