-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
executable file
·49 lines (41 loc) · 1.15 KB
/
main.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2013 Hugo Lindström <hugolm84@gmail.com>
#
#
# local includes
#
from hemnet import hemnet
#
# flask includes
#
from flask import Flask
from werkzeug.routing import BaseConverter
#
# twisted is our new web backend
#
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
# Twisted logging
import sys
from twisted.python import log
from twisted.python.logfile import DailyLogFile
DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
# custom url converter
class RegexConverter(BaseConverter):
def __init__(self, url_map, *items):
super(RegexConverter, self).__init__(url_map)
self.regex = items[0]
app.url_map.converters['regex'] = RegexConverter
app.register_blueprint(hemnet)
if __name__ == '__main__':
if DEBUG :
log.startLogging(sys.stdout)
#log.startLogging(DailyLogFile.fromFullPath("logs/charts-twisted.log"))
# Start the service
resource = WSGIResource(reactor, reactor.getThreadPool(), app)
reactor.listenTCP(8080, Site(resource), interface="10.0.1.8")
reactor.run()