allow importing the app without running the server
This commit is contained in:
parent
537b728dd8
commit
5136934e18
18
main.py
18
main.py
@ -41,7 +41,6 @@ CONFIG = {
|
|||||||
"http://repo.msys2.org/msys/x86_64/msys.files": ("msys", "x86_64"),
|
"http://repo.msys2.org/msys/x86_64/msys.files": ("msys", "x86_64"),
|
||||||
}
|
}
|
||||||
|
|
||||||
PORT = 8160
|
|
||||||
UPDATE_INTERVAL = 60 * 15
|
UPDATE_INTERVAL = 60 * 15
|
||||||
|
|
||||||
sources = []
|
sources = []
|
||||||
@ -366,22 +365,19 @@ def update_thread():
|
|||||||
time.sleep(UPDATE_INTERVAL)
|
time.sleep(UPDATE_INTERVAL)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
thread = threading.Thread(target=update_thread)
|
||||||
global app
|
thread.daemon = True
|
||||||
|
thread.start()
|
||||||
|
|
||||||
thread = threading.Thread(target=update_thread)
|
|
||||||
thread.daemon = True
|
|
||||||
thread.start()
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.web.server import Site
|
from twisted.web.server import Site
|
||||||
from twisted.web.wsgi import WSGIResource
|
from twisted.web.wsgi import WSGIResource
|
||||||
|
|
||||||
|
port = 8160
|
||||||
wsgiResource = WSGIResource(reactor, reactor.getThreadPool(), app)
|
wsgiResource = WSGIResource(reactor, reactor.getThreadPool(), app)
|
||||||
site = Site(wsgiResource)
|
site = Site(wsgiResource)
|
||||||
print("http://localhost:%d" % PORT)
|
print("http://localhost:%d" % port)
|
||||||
reactor.listenTCP(PORT, site)
|
reactor.listenTCP(port, site)
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user