Sign inSign up

sabbir1cse/python36_wsgi_socket

By sabbir1cse

Updated almost 8 years ago

Python 3.6 Flask Based Socket.io Image

Image
0

696

sabbir1cse/python36_wsgi_socket repository overview

A Sample App located at **/code ** directory.

Sample python file app.py
import 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)
Sample entry point file run.sh
#! /usr/bin/env bash
# Port 5001
## For development
# python3 app.py 

## For Production
# gunicorn --worker-class eventlet -w 1 app:app -b :5001

Tag summary

Content type

Image

Digest

Size

365.1 MB

Last updated

about 8 years ago

docker pull sabbir1cse/python36_wsgi_socket