Coder Social home page Coder Social logo

abhimishka / websocket-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nschwermann/websocket-server

0.0 2.0 0.0 213 KB

Example of websocket server using python tornado library. Companion Android application found here.

Home Page: https://github.com/schwiz/android-websocket-example

Python 46.72% JavaScript 30.18% CSS 8.78% HTML 14.32%

websocket-server's Introduction

Websocket Server Example

Nathan Schwermann

Requires python, tornado, and nginx

pip install tornado

python sockets.py

Visit the webpage demo at http://localhost/list using the NGINX site configuration below (it is possible to use without nginx but sockets.py will need to be tweaked to load static files)

upstream tornado {
  server 127.0.0.1:8888;
}

server {
  listen 80 default; ## listen for ipv4; this line is default and implied
  #listen   [::]:80 default ipv6only=on; ## listen for ipv6

  root /var/www;
  index index.html index.htm index.php;

  # Make site accessible from http://localhost/
  server_name localhost;

  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to index.html
    try_files $uri $uri/ /index.html;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
  }

  location /list/static/{

  }

  location /list {
    root /var/www/list/;
    if ($query_string) {
      expires max;
    }
    proxy_pass http://tornado;
    proxy_http_version 1.1;
    proxy_pass_header Server;
    proxy_redirect off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
  }

  location /doc/ {
    alias /usr/share/doc/;
    autoindex on;
    allow 127.0.0.1;
    deny all;
  }

}

The following supervisor configuration can be used to keep the tornado instance running

[program:tornado]
command=python /var/www/list/sockets.py
stdout_logfile=/var/www/list/log.txt
redirect_stderr=true

Liscence

Copyright 2013 Nathan Schwermann

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

websocket-server's People

Watchers

James Cloos avatar Abhishek  avatar

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.