diff --git a/GpsTrackerServer/GpsTrackerServer.pyproj b/GpsTrackerServer/GpsTrackerServer.pyproj deleted file mode 100644 index 7082fa1..0000000 --- a/GpsTrackerServer/GpsTrackerServer.pyproj +++ /dev/null @@ -1,89 +0,0 @@ - - - 10.0 - Debug - 2.0 - 38a5dbf7-8f3d-4c79-b589-ab52837ba180 - . - {1b580a1a-fdb3-4b32-83e1-6407eb2722e6};{349c5851-65df-11da-9384-00065b846f21};{888888a0-9f3d-457c-b088-3a5042f75d52} - main.py - - - . - Web launcher - http://localhost - . - true - GpsTrackerServer - GpsTrackerServer - Global|PythonCore|3.6 - - - true - false - - - true - false - - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - - - - - - - True - True - http://localhost - False - - - - - - - CurrentPage - True - False - False - False - - - - - - - - - False - False - - - - - \ No newline at end of file diff --git a/GpsTrackerServer/api.py b/GpsTrackerServer/api.py deleted file mode 100644 index b2fd90b..0000000 --- a/GpsTrackerServer/api.py +++ /dev/null @@ -1,16 +0,0 @@ -import falcon -import middlewares -import resources -import constants - -#from constants import * - -def create(): - api = falcon.API(media_type=constants.MEDIA_CSV, middleware=[ - middlewares.AuthMiddleware(constants.USER_AGENT), - middlewares.RequireCSV() - ]) - - api.add_route(constants.ROUTES_POSITIONS, resources.PositionsResource()) - - return api \ No newline at end of file diff --git a/GpsTrackerServer/constants.py b/GpsTrackerServer/constants.py deleted file mode 100644 index 6cbbbba..0000000 --- a/GpsTrackerServer/constants.py +++ /dev/null @@ -1,4 +0,0 @@ -USER_AGENT = 'SIMCOM_MODULE' -MEDIA_CSV = 'text/csv' - -ROUTES_POSITIONS = '/positions' diff --git a/GpsTrackerServer/main.py b/GpsTrackerServer/main.py deleted file mode 100644 index b559f47..0000000 --- a/GpsTrackerServer/main.py +++ /dev/null @@ -1,13 +0,0 @@ -""" -Basic HTTP server to receive and save gps positions sent by Arduino GPS Tracker -""" - -import api - -if __name__ == "__main__": - # Use python built-in WSGI reference implemention to run a web server - from wsgiref.simple_server import make_server - - print('Starting web server...') - srv = make_server('localhost', 8080, api.create()) - srv.serve_forever() diff --git a/GpsTrackerServer/middlewares.py b/GpsTrackerServer/middlewares.py deleted file mode 100644 index 51d801a..0000000 --- a/GpsTrackerServer/middlewares.py +++ /dev/null @@ -1,24 +0,0 @@ -import falcon -import constants - -class RequireCSV(object): - - def process_request(self, req, resp): - if req.method in ('POST', 'PUT'): - if constants.MEDIA_CSV not in req.content_type: - raise falcon.HTTPUnsupportedMediaType - -class AuthMiddleware(object): - - def __init__(self, userAgentRequired): - self._userAgentRequired = userAgentRequired - - def process_request(self, req, resp): - authorization = req.get_header('Authorization') - userAgent = req.get_header('User-Agent') - - if userAgent != self._userAgentRequired: - if authorization is None: #make clients believe that Authorization header is the issue - raise falcon.HTTPForbidden - else: - raise falcon.HTTPUnauthorized diff --git a/GpsTrackerServer/resources.py b/GpsTrackerServer/resources.py deleted file mode 100644 index 579bdf1..0000000 --- a/GpsTrackerServer/resources.py +++ /dev/null @@ -1,11 +0,0 @@ -import falcon - -class PositionsResource: - - def on_post(self, req, resp): - data = req.bounded_stream.read() - resp.body = data - resp.status = falcon.HTTP_201 - - def on_get(self, req, resp): - raise falcon.HTTPNotImplemented