Skip to content

Commit 33ea496

Browse files
committed
Merge branch 'master' of http://github.com/bashwork/speleo
2 parents 2b83641 + 4b00f7c commit 33ea496

File tree

105 files changed

+74120
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+74120
-0
lines changed

service/handlers/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from root_handler import RootHandler
2+
from contact_handler import ContactHandler
3+
from simple_handlers import *

service/handlers/common.py

Whitespace-only changes.

service/handlers/contact_handler.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import tornado.web
2+
3+
class ContactHandler(tornado.web.RequestHandler):
4+
5+
RoutePath = r'/contact'
6+
7+
def get(self):
8+
self.render('contact.html')
9+
10+
def post(self):
11+
subject = self.get_argument('subject', '')
12+
email = self.get_argument('email', '')
13+
message = self.get_argument('message', '')
14+
self.write(subject + ' ' + email + ' ' + message)
15+

service/handlers/root_handler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import tornado.web
2+
3+
class RootHandler(tornado.web.RequestHandler):
4+
5+
RoutePath = r'/'
6+
7+
def get(self, **kwargs):
8+
self.render('index.html')

service/handlers/simple_handlers.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import tornado.web
2+
3+
class AboutHandler(tornado.web.RequestHandler):
4+
5+
RoutePath = r'/about'
6+
7+
def get(self):
8+
self.render('about.html')
9+
10+
class AnalyzeHandler(tornado.web.RequestHandler):
11+
12+
RoutePath = r'/analyze'
13+
14+
def get(self):
15+
self.render('analyze.html')
16+
17+
class QueryHandler(tornado.web.RequestHandler):
18+
19+
RoutePath = r'/query'
20+
21+
def get(self):
22+
self.render('query.html')
23+
24+
class HealthHandler(tornado.web.RequestHandler):
25+
26+
RoutePath = r'/health'
27+
28+
def get(self):
29+
self.render('health.html')

service/main.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
import os.path
3+
import inspect
4+
import logging
5+
import handlers
6+
import tornado.ioloop
7+
import tornado.web
8+
from tornado.options import define, options
9+
10+
# ------------------------------------------------------------
11+
# options
12+
# ------------------------------------------------------------
13+
define("port", default=8888, help="run on the given port", type=int)
14+
15+
# ------------------------------------------------------------
16+
# settings
17+
# ------------------------------------------------------------
18+
settings = {
19+
'static_path': os.path.join(os.path.dirname(__file__), 'static'),
20+
'template_path': os.path.join(os.path.dirname(__file__), 'templates'),
21+
'login_url':'/auth/login',
22+
'debug': True,
23+
}
24+
25+
# ------------------------------------------------------------
26+
# handlers
27+
# ------------------------------------------------------------
28+
search = inspect.getmembers(handlers)
29+
routes = [(h.RoutePath, h) for n,h in search if 'Handler' in n]
30+
31+
# ------------------------------------------------------------
32+
# main service
33+
# ------------------------------------------------------------
34+
if __name__ == "__main__":
35+
tornado.options.parse_command_line()
36+
application = tornado.web.Application(routes, **settings)
37+
logging.debug('Installed Handlers')
38+
for route in routes: logging.debug(route)
39+
application.listen(options.port)
40+
tornado.ioloop.IOLoop.instance().start()

0 commit comments

Comments
 (0)