Skip to content

Commit

Permalink
add command parser
Browse files Browse the repository at this point in the history
  • Loading branch information
RicterZ committed Mar 22, 2015
1 parent 197c8d8 commit 8dee93d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/server.py → src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import websocket
import tornado.web
import tornado.ioloop
import tornado.httpserver
import websocket
from tornado.options import define, options


class MainHandler(tornado.web.RequestHandler):
Expand All @@ -15,6 +16,7 @@ def get(self):
if not url.startswith('ws://') and not url.startswith('wss://'):
raise Exception('Invaild WebSocket Url, example: ws://127.0.0.1/chat')

print 'Request Payload: %s' % data
ws = websocket.WebSocket()
ws.connect(url)
ws.send(data)
Expand All @@ -32,7 +34,9 @@ def __init__(self):


if __name__ == '__main__':
define('port', default=8888, help='Port listened')
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(8889)
http_server.listen(options.port)

print 'WebSocket Injection Server Listenning on %d' % options.port
tornado.ioloop.IOLoop.instance().start()

0 comments on commit 8dee93d

Please sign in to comment.