-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresale_web.py
56 lines (44 loc) · 1.74 KB
/
resale_web.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import logging
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.autoreload
from tornado.web import URLSpec
logging.basicConfig(filename='resale.log', level=logging.DEBUG)
from resalepost import ResalePostHandler, ResalePostViewHandler
from resalepost import ResalePostImageHandler, ResalePostSearchHandler
from resale_telephony import ResaleTwilioRequestHandler, ResaleGetSellerPhoneNumberHandler
class MainHandler(tornado.web.RequestHandler):
def get(self):
# TODO: promotional home page
self.write("Hello, world")
class AuthHandler(tornado.web.RequestHandler):
# TODO: authentication
pass
settings = {
"static_path": os.path.join(os.path.dirname(__file__), "static"),
}
print 'settings', settings
print
application = tornado.web.Application([
URLSpec(r"/", MainHandler),
URLSpec(r"/auth", AuthHandler),
# ReSale posts (things for sale or for free)
URLSpec(r"/post", ResalePostHandler, name="post"),
# TODO: app should send image straight to S3 or some CDN, not to API
URLSpec(r"/post/image", ResalePostImageHandler),
URLSpec(r"/post/search", ResalePostSearchHandler),
URLSpec(r"/post/get_seller_phone_number", ResaleGetSellerPhoneNumberHandler, name='get_seller_phone_number'),
URLSpec(r"/post/(\S+)", ResalePostViewHandler, name="view_post"),
# Twilio interaction
URLSpec(r"/twilio/request", ResaleTwilioRequestHandler),
], **settings)
if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(80)
print 'listening on port 80'
logging.info('logger up')
# TODO: don't autoreload in production
tornado.autoreload.start()
tornado.ioloop.IOLoop.instance().start()