Git Product home page Git Product logo

websocket_http_server's Introduction

Websocket_HTTP_Server

Websocket_HTTP_Server is a collection of files that will easily display a set of data being gathered over a web browser, the collection was originally built to display thermal images over http/tcp port 80 in a real-time fashion. When connecting to the http server, the server delivers index.html that will launch a javascript program on load. This program connects to the websocket server, where the websocket server streams data down to all the clients.

This program is uses the package from python-websocket-server, which I installed using sudo pip install websocket-server. Furthermore, in the /usr/local/lib/python2.7/dist-packages/websocket_server the python program websocket_server.py is installed. I edited this file and commented out line 207, which is responsible for the error message "Can't send message, message is not valid UTF-8", because when opening the image that another thread is still writing to, there will an incomplete file that is to be read. The error message will not break the program I wrote, but will spam the command line.

alt-text

By running websocket_http_server.py, the python program will startup an http server and a websocket server which will pull configuration settings from server.conf which also has a file path to the image that will be constantly sent in a loop. The program will encode thermal.jpg into a base64 format and send it over the websocket connection.

alt-text

shift.sh is a shell script that copies thermal2-thermal4.jpg into thermal.jpg which will be displayed. You will need to run sudo chmod u+x shift.sh and run it as root, we used this as a test to ensure that the stream of data was running to the clients by shuffling the images into thermal.jpg.

alt-text

index.html is server by the http server, which onload will hook into the websocket server. index.html will collect the data that is being streamed from the websocket server and display it as an image by decoding the image and placing it on the web browser. index.html handles the formating of the image in terms of the dimensions that it will be displayed as.

ENSURE THAT YOU CHANGE THE IP ADDRESS OF VAR S = new WebSocket(ws://X.X.X.X:PORT) TO ESTABLISH CONNECTION TO YOUR WEBSOCKET SERVER

alt-text

server.conf is the configuration file that websocket_http_server.py will use in order to determine that port and interface numbers that the servers will broadcast on.

alt-text

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.