Here is the code that I have tried:
if __name__ == "__main__":
#create new web app w/ websocket endpoint available at /websocket
print ("Starting websocket server program. Awaiting client requests to open websocket ...")
application = web.Application([(r'/static/(.*)', web.StaticFileHandler, {'path': os.path.dirname(__file__)}),
(r'/websocket', WebSocketHandler)])
application.listen(8001)
ioloop.IOLoop.instance().start()
The error I got is:
NameError Traceback (most recent call last)
<ipython-input-41-cdf099b27f7d> in <module>()
2 #create new web app w/ websocket endpoint available at /websocket
3 print ("Starting websocket server program. Awaiting client requests to open websocket ...")
----> 4 application = web.Application([(r'/static/(.*)', web.StaticFileHandler, {'path': os.path.dirname(__file__)}),
5 (r'/websocket', WebSocketHandler)])
6 application.listen(8001)
NameError: name '__file__' is not defined
So I try to remove the __file__
from the command:
if __name__ == "__main__":
#create new web app w/ websocket endpoint available at /websocket
print ("Starting websocket server program. Awaiting client requests to open websocket ...")
application = web.Application([(r'/'),
(r'/websocket', WebSocketHandler)])
application.listen(8001)
ioloop.IOLoop.instance().start()
Go the following error:
AttributeError: 'str' object has no attribute 'name'
Kindly, help me in understanding the missing part as I guess I missed something.