diff --git a/Python/Main.py b/Python/Main.py index 77b7364ab..b328af8de 100644 --- a/Python/Main.py +++ b/Python/Main.py @@ -1,4 +1,13 @@ -import WebSiteHandler +# import WebSiteHandler +import tornado.ioloop + +from app.Chameleon_Vision_App import ChameleonApplication +from tornado.options import options if __name__ == "__main__": - WebSiteHandler.run_all() + # WebSiteHandler.run_all() + tornado.options.parse_command_line() + app = ChameleonApplication() + print(f"Serving on port {options.port}") + app.listen(options.port) + tornado.ioloop.IOLoop.current().start() diff --git a/Python/WebSiteHandler.py b/Python/WebSiteHandler.py index 7ee38ba81..b0c12c0f3 100644 --- a/Python/WebSiteHandler.py +++ b/Python/WebSiteHandler.py @@ -32,3 +32,4 @@ def run_all(): socket_process = multiprocessing.Process(target=test) html_process.start() socket_process.start() + diff --git a/Python/__init__.py b/Python/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/Python/app/Chameleon_Vision_App.py b/Python/app/Chameleon_Vision_App.py new file mode 100644 index 000000000..9f4825e65 --- /dev/null +++ b/Python/app/Chameleon_Vision_App.py @@ -0,0 +1,21 @@ +import tornado.web +import tornado.websocket +import os + +from handlers.MainHandler import MainHandler +from tornado.options import define + +define("port", default=8888, help="run on the given port", type=int) + + +class ChameleonApplication(tornado.web.Application): + def __init__(self): + handlers = [(r"/", MainHandler), + (r"/CSS/(.*)", tornado.web.StaticFileHandler, {'path': os.path.join(os.path.dirname(__file__), "../../Site/CSS")}), + (r"/JS/(.*)", tornado.web.StaticFileHandler, + {'path': os.path.join(os.path.dirname(__file__), "../../Site/JS")})] + settings = dict( + template_path=os.path.join(os.path.dirname(__file__), "../../Site") + ) + + super(ChameleonApplication, self).__init__(handlers, **settings) diff --git a/Python/app/__init__.py b/Python/app/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/Python/app/__pycache__/Chameleon_Vision_App.cpython-37.pyc b/Python/app/__pycache__/Chameleon_Vision_App.cpython-37.pyc new file mode 100644 index 000000000..5a3d78b99 Binary files /dev/null and b/Python/app/__pycache__/Chameleon_Vision_App.cpython-37.pyc differ diff --git a/Python/app/__pycache__/__init__.cpython-37.pyc b/Python/app/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 000000000..38d5bf51e Binary files /dev/null and b/Python/app/__pycache__/__init__.cpython-37.pyc differ diff --git a/Python/app/handlers/MainHandler.py b/Python/app/handlers/MainHandler.py new file mode 100644 index 000000000..d259343af --- /dev/null +++ b/Python/app/handlers/MainHandler.py @@ -0,0 +1,6 @@ +import tornado.web + + +class MainHandler(tornado.web.RequestHandler): + def get(self): + self.render("index.html") diff --git a/Python/app/handlers/__init__.py b/Python/app/handlers/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/Python/app/handlers/__pycache__/MainHandler.cpython-37.pyc b/Python/app/handlers/__pycache__/MainHandler.cpython-37.pyc new file mode 100644 index 000000000..025cebc76 Binary files /dev/null and b/Python/app/handlers/__pycache__/MainHandler.cpython-37.pyc differ diff --git a/Python/app/handlers/__pycache__/__init__.cpython-37.pyc b/Python/app/handlers/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 000000000..c30c4aba9 Binary files /dev/null and b/Python/app/handlers/__pycache__/__init__.cpython-37.pyc differ diff --git a/Site/Index.html b/Site/Index.html index 756dc5acb..6e3f06436 100644 --- a/Site/Index.html +++ b/Site/Index.html @@ -3,7 +3,7 @@ Chameleon Vision - +