瀏覽代碼

The gps tracker server now has its own repository

tags/v1.2.0
Bertrand Lemasle 7 年之前
父節點
當前提交
16a50cf531
共有 6 個檔案被更改,包括 0 行新增157 行删除
  1. +0
    -89
      GpsTrackerServer/GpsTrackerServer.pyproj
  2. +0
    -16
      GpsTrackerServer/api.py
  3. +0
    -4
      GpsTrackerServer/constants.py
  4. +0
    -13
      GpsTrackerServer/main.py
  5. +0
    -24
      GpsTrackerServer/middlewares.py
  6. +0
    -11
      GpsTrackerServer/resources.py

+ 0
- 89
GpsTrackerServer/GpsTrackerServer.pyproj 查看文件

@@ -1,89 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>38a5dbf7-8f3d-4c79-b589-ab52837ba180</ProjectGuid>
<ProjectHome>.</ProjectHome>
<ProjectTypeGuids>{1b580a1a-fdb3-4b32-83e1-6407eb2722e6};{349c5851-65df-11da-9384-00065b846f21};{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
<StartupFile>main.py</StartupFile>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<LaunchProvider>Web launcher</LaunchProvider>
<WebBrowserUrl>http://localhost</WebBrowserUrl>
<OutputPath>.</OutputPath>
<SuppressCollectPythonCloudServiceFiles>true</SuppressCollectPythonCloudServiceFiles>
<Name>GpsTrackerServer</Name>
<RootNamespace>GpsTrackerServer</RootNamespace>
<InterpreterId>Global|PythonCore|3.6</InterpreterId>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Compile Include="api.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="constants.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="main.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="middlewares.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="resources.py">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<InterpreterReference Include="Global|PythonCore|3.6" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.Web.targets" />
<!-- Specify pre- and post-build commands in the BeforeBuild and
AfterBuild targets below. -->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<AutoAssignPort>True</AutoAssignPort>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://localhost</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}" User="">
<WebProjectProperties>
<StartPageUrl>
</StartPageUrl>
<StartAction>CurrentPage</StartAction>
<AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging>
<NativeDebugging>False</NativeDebugging>
<SQLDebugging>False</SQLDebugging>
<ExternalProgram>
</ExternalProgram>
<StartExternalURL>
</StartExternalURL>
<StartCmdLineArguments>
</StartCmdLineArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
<EnableENC>False</EnableENC>
<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>

+ 0
- 16
GpsTrackerServer/api.py 查看文件

@@ -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

+ 0
- 4
GpsTrackerServer/constants.py 查看文件

@@ -1,4 +0,0 @@
USER_AGENT = 'SIMCOM_MODULE'
MEDIA_CSV = 'text/csv'

ROUTES_POSITIONS = '/positions'

+ 0
- 13
GpsTrackerServer/main.py 查看文件

@@ -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()

+ 0
- 24
GpsTrackerServer/middlewares.py 查看文件

@@ -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

+ 0
- 11
GpsTrackerServer/resources.py 查看文件

@@ -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

Loading…
取消
儲存