Skip to content

Commit 140bea3

Browse files
committed
Add prototype web interface
1 parent f971bdc commit 140bea3

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

cloudbot/web.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import asyncio
2+
3+
from tornado.web import RequestHandler, Application, url
4+
from tornado.platform.asyncio import AsyncIOMainLoop
5+
6+
7+
def get_application():
8+
app = Application([
9+
url('/', TestHandler)
10+
])
11+
return app
12+
13+
14+
class TestHandler(RequestHandler):
15+
def get(self):
16+
self.write("Hello world!\n")
17+
18+
19+
class WebInterface():
20+
def __init__(self, bot, port=8080, address="0.0.0.0"):
21+
self.bot = bot
22+
self.port = port
23+
self.address = address
24+
25+
self.app = None
26+
27+
# Install tornado IO loop.
28+
AsyncIOMainLoop().install()
29+
30+
def start(self):
31+
""" Starts the CloudBot web application """
32+
self.app = get_application()
33+
self.app.listen(self.port, address=self.address)

0 commit comments

Comments
 (0)