From 1960cd434b3e401a6e92b21c172e0b9f78971830 Mon Sep 17 00:00:00 2001 From: Sagi Frimer Date: Fri, 1 Mar 2019 20:16:04 +0200 Subject: [PATCH] Initial tornado application --- Python/Main.py | 13 +++++++++-- Python/WebSiteHandler.py | 1 + Python/__init__.py | 0 Python/app/Chameleon_Vision_App.py | 21 ++++++++++++++++++ Python/app/__init__.py | 0 .../Chameleon_Vision_App.cpython-37.pyc | Bin 0 -> 1033 bytes .../app/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 147 bytes Python/app/handlers/MainHandler.py | 6 +++++ Python/app/handlers/__init__.py | 0 .../__pycache__/MainHandler.cpython-37.pyc | Bin 0 -> 506 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 156 bytes Site/Index.html | 2 +- 12 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 Python/__init__.py create mode 100644 Python/app/Chameleon_Vision_App.py create mode 100644 Python/app/__init__.py create mode 100644 Python/app/__pycache__/Chameleon_Vision_App.cpython-37.pyc create mode 100644 Python/app/__pycache__/__init__.cpython-37.pyc create mode 100644 Python/app/handlers/MainHandler.py create mode 100644 Python/app/handlers/__init__.py create mode 100644 Python/app/handlers/__pycache__/MainHandler.cpython-37.pyc create mode 100644 Python/app/handlers/__pycache__/__init__.cpython-37.pyc 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 0000000000000000000000000000000000000000..5a3d78b99f59e6bb6b5033575a274c322969a90a GIT binary patch literal 1033 zcmZWo&2H2%5VoD{Ci@3elpi6GR-6ceU2#PS0Tr|ts!A&XidHfq_I90mlVE#`x@u3Y zR4(Ni=#e+zS$yThEA+%TyW6gW6OU&+lkqp-IBz%TWjA6-@mJ z1Vao<6ys_oi`9!gu!;01wYY{|j3?`pAPz9%0rOdn)p^K*GasW(#6s3ML9D@X*2tR2 zUfg1MfTHGK$d0xnY+LUWk#8kAlU#vWXM7}bZvC=QM*Mz=(Cn6)=G`LinlbP0ihZ7U zoiFli0I|tb8tad_EUj-2N}jsB%i%2)eIFEF)e)0ZG{OusauUYgDe_V510K(=Z;X=( zm%PYdm!%YGVnmUrc#*+nYQS`>{tSX)gGPiAgENwO%rkyg`&qAKV8V0E{Bt7k$lE1H z*fjq0*3Jp5pW!27nx=J#j!D)Ou2eqhHaAPTlGaDUe5Zwv`pFp`+@>{_qa zhj$?W#Bl0@qmF{^A{&@OId?FWyQsBb^Wn!r?F~1D>F%f^mtHHX?&1{F0aofK?ZRoABU>ok#bPnFts7O+z; zC8g>P98!r0tJ_Y$>x4VI1yehkLtNQWJ8mub?g8D(`Qx>f9bKe*+^CM*UtdzzTlov- zO}oDQq$u4@)XH5w>xtYbSGR4gR9GE+g>kMqgf@IJFY=|k$l84vVt7a!x5*9fABJ-k A4FCWD literal 0 HcmV?d00001 diff --git a/Python/app/__pycache__/__init__.cpython-37.pyc b/Python/app/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..38d5bf51e8ea598d4809f040c7580041b3916d89 GIT binary patch literal 147 zcmZ?b<>g`kg0GpCF(CReh=2h`Aj1KOi&=m~3PUi1CZpd`(0P?VpQnp{#G+Xgd^nu literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..025cebc766f8ed5945d9023e832a5ee0c2a8e352 GIT binary patch literal 506 zcmYjN%}xR_5N@~2k05yQ0l0FI2QbDEiGhoRXrjqxlV+vWU0k-%mMDb8gFJ{HeWhMK z`3jz#*@a{$nZHiIuV3e?)oKv1BfAdYA^%`=FdvFOxamL;M9`E3bV!6J*p3J$>CBt4 z4;J`>-jS~V3%AI4it%6`6n$`W3PA!|kiZjEcsmj>!4Tz|H&K#}qD-VxPbu6(!_2@3 z;HC{>OFlus7o{KsVBUDsNHQVcda<3SUFxb@LaU+jjZB}uiLLR g47>KNT&|?C`{m_`5-Y0JNbTwug_uiRYr)U{0gX9#>i_@% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c30c4aba976b7e498053eb11dae59d60922f17c9 GIT binary patch literal 156 zcmZ?b<>g`kg0ESXF(CReh=2h`Aj1KOi&=m~3PUi1CZpd`(0P?VpQnp{#GRbv literal 0 HcmV?d00001 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 - +