Skip to main content

A modified websocket-server that supports communication on the same port as flask

Project description

Language

FloraServer

By inheriting a large number of modified websocket-server library classes to customize a network router, splitting regular HTTP connections from WebSocket connections, and constructing a WSGI environment and HTTP request headers to call flask, websocket-server and flask can communicate on the same port

How to use it?

  1. You can choose to directly 'clone' this repository into your project
  2. Use the following command to install
pip install FloraServer
  1. Import FloraServer into your project From FloraServer import [class] There are two WebSocketServer classes in this project, one is FloraFlaskWSServer, the protagonist of this repository, and the other is FloraWebsocket Server, which is not much different from Websocket Server, only with relatively loose connections
  2. To start using, follow the development documentation for flask and websocket-server

Code Demonstration

from FloraServer import FloraFlaskWSServer
from flask import Flask

app = Flask(__name__)

@app.route("/")
def index():
    return "Hello world!"


def on_message(client, server, message):
    print(message)


if __name__ == "__main__":
    server = FloraFlaskWSServer(flask_app=app, host="0.0.0.0", port=5000)
    server.set_fn_message_received(on_message)
    server.run_forever()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

floraserver-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

floraserver-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file floraserver-0.1.0.tar.gz.

File metadata

  • Download URL: floraserver-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.3 CPython/3.13.1 Linux/6.8.0-1020-azure

File hashes

Hashes for floraserver-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b0347cf35f7fd8e2cfb138f92d90c6ecd66387c93c4ff46534497db4c60d9fac
MD5 3b2ae3b834d97876d5ca1c1f4b8f7efd
BLAKE2b-256 dac39e49aad812724e3ca78a181e5b40a392fa3c2e0a2684938d8dea5ae90462

See more details on using hashes here.

File details

Details for the file floraserver-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: floraserver-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.3 CPython/3.13.1 Linux/6.8.0-1020-azure

File hashes

Hashes for floraserver-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc86938c62a3fa685606cefd45a9d3092f66e75ecceb6990c62f403bf076358a
MD5 7ef3edf580beaaaabfb81f846b53d29a
BLAKE2b-256 fcace0126d0e24381ef657e9f923e638e964b3444b49b1f60034a5d5a55d4bef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page