-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
executable file
·31 lines (25 loc) · 874 Bytes
/
server.py
File metadata and controls
executable file
·31 lines (25 loc) · 874 Bytes
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
from twisted.web import server
from twisted.web.resource import Resource
from twisted.internet import reactor, endpoints
from twisted.web.server import Site
from twisted.web.static import File
class Router(Resource):
def __init__(self):
Resource.__init__(self)
self.putChild("js", File("./scripts/js"))
self.putChild("css", File("./scripts/css"))
def getChild(self,path,request):
controller = None
if(request.uri == '/'):
controller = 'homeController'
else:
controller = request.uri.split('/')[1] + 'Controller'
print(controller)
return getattr(getattr(Controllers,controller),controller)()
def StartServer():
factory = Site(IController())
reactor.listenTCP(8080, factory)
reactor.run()
if __name__ == '__main__':
execfile('__init__.py')
StartServer()