Python 3.6 Flask Based Socket.io Image
696
A Sample App located at **/code ** directory.
docker run -itd -v $(pwd):/code -p 5001:5001 abbir1cse/python36_wsgi_socket:tagimport requests
import json
from threading import Lock
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
from requests import Request, Session
# Set this variable to "threading", "eventlet" or "gevent" to test the
# different async modes, or leave it set to None for the application to choose
# the best option based on installed packages.
async_mode = None
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app, async_mode=async_mode)
thread = None
thread_lock = Lock()
s = Session()
@app.route('/')
def index():
return render_template('index.html', async_mode=socketio.async_mode)
@socketio.on('custom_event', namespace='/myevent')
def message(message):
emit('my_response', {'data': "I'm fine"})
if __name__ == '__main__':
socketio.run(app, debug=True, host='0.0.0.0', port=5001)
#! /usr/bin/env bash
# Port 5001
## For development
# python3 app.py
## For Production
# gunicorn --worker-class eventlet -w 1 app:app -b :5001
Content type
Image
Digest
Size
365.1 MB
Last updated
about 8 years ago
docker pull sabbir1cse/python36_wsgi_socket