mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Starting implementation of posting spots #2
This commit is contained in:
@@ -30,6 +30,7 @@ class WebServer:
|
|||||||
bottle.get("/api/spots")(lambda: self.serve_api(self.get_spot_list_with_filters()))
|
bottle.get("/api/spots")(lambda: self.serve_api(self.get_spot_list_with_filters()))
|
||||||
bottle.get("/api/options")(lambda: self.serve_api(self.get_options()))
|
bottle.get("/api/options")(lambda: self.serve_api(self.get_options()))
|
||||||
bottle.get("/api/status")(lambda: self.serve_api(self.status_data))
|
bottle.get("/api/status")(lambda: self.serve_api(self.status_data))
|
||||||
|
bottle.post("/api/spot")(lambda: self.accept_spot())
|
||||||
# Routes for templated pages
|
# Routes for templated pages
|
||||||
bottle.get("/")(lambda: self.serve_template('webpage_home'))
|
bottle.get("/")(lambda: self.serve_template('webpage_home'))
|
||||||
bottle.get("/about")(lambda: self.serve_template('webpage_about'))
|
bottle.get("/about")(lambda: self.serve_template('webpage_about'))
|
||||||
@@ -55,6 +56,17 @@ class WebServer:
|
|||||||
response.set_header('Cache-Control', 'no-store')
|
response.set_header('Cache-Control', 'no-store')
|
||||||
return json.dumps(data, default=serialize_everything)
|
return json.dumps(data, default=serialize_everything)
|
||||||
|
|
||||||
|
# Accept a spot
|
||||||
|
def accept_spot(self):
|
||||||
|
self.last_api_access_time = datetime.now(pytz.UTC)
|
||||||
|
self.status = "OK"
|
||||||
|
|
||||||
|
print(bottle.request.forms.spot)
|
||||||
|
|
||||||
|
response.content_type = 'application/json'
|
||||||
|
response.set_header('Cache-Control', 'no-store')
|
||||||
|
return json.dumps("OK", default=serialize_everything)
|
||||||
|
|
||||||
# Serve a templated page
|
# Serve a templated page
|
||||||
def serve_template(self, template_name):
|
def serve_template(self, template_name):
|
||||||
self.last_page_access_time = datetime.now(pytz.UTC)
|
self.last_page_access_time = datetime.now(pytz.UTC)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ paths:
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- spots
|
- spots
|
||||||
summary: Retrieve a set of spots.
|
summary: Get spots
|
||||||
description: The main API call that retrieves spots from the system. Supply this with no query parameters to retrieve all spots known to the system. Supply query parameters to filter what is retrieved.
|
description: The main API call that retrieves spots from the system. Supply this with no query parameters to retrieve all spots known to the system. Supply query parameters to filter what is retrieved.
|
||||||
operationId: spots
|
operationId: spots
|
||||||
parameters:
|
parameters:
|
||||||
@@ -170,7 +170,7 @@ paths:
|
|||||||
- AN
|
- AN
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successfully retrieved spots.
|
description: Success
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
@@ -183,12 +183,12 @@ paths:
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- status
|
- status
|
||||||
summary: Retrieve the server status.
|
summary: Get server status
|
||||||
description: Query information about the server for use in a diagnostics display
|
description: Query information about the server for use in a diagnostics display.
|
||||||
operationId: status
|
operationId: status
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successfully retrieved status.
|
description: Success
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
@@ -251,12 +251,12 @@ paths:
|
|||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- spots
|
- spots
|
||||||
summary: Retieve a list of options for various enumerations.
|
summary: Get enumeration options
|
||||||
description: Retrieves the list of options for various enumerated types, which can be found in the spots and also provided back to the API as query parameters. While these enumerated options are defined in this spec anyway, providing them in an API call allows us to define extra parameters, like the colours associated with bands, and also allows clients to set up their filters and features without having to have internal knowledge about, for example, what bands the server knows about.
|
description: Retrieves the list of options for various enumerated types, which can be found in the spots and also provided back to the API as query parameters. While these enumerated options are defined in this spec anyway, providing them in an API call allows us to define extra parameters, like the colours associated with bands, and also allows clients to set up their filters and features without having to have internal knowledge about, for example, what bands the server knows about.
|
||||||
operationId: options
|
operationId: options
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successfully retrieved options.
|
description: Success
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
@@ -302,6 +302,38 @@ paths:
|
|||||||
description: The maximum age, in seconds, of any spot before it will be deleted by the system. When querying the /api/spots endpoint and providing a "max_age" or "since" parameter, there is no point providing a number larger than this, because the system drops all spots older than this.
|
description: The maximum age, in seconds, of any spot before it will be deleted by the system. When querying the /api/spots endpoint and providing a "max_age" or "since" parameter, there is no point providing a number larger than this, because the system drops all spots older than this.
|
||||||
example: 3600
|
example: 3600
|
||||||
|
|
||||||
|
|
||||||
|
/spot:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- spots
|
||||||
|
summary: Add a spot
|
||||||
|
description: Supply a new spot object, which will be added to the system. Currently, this will not be reported up the chain to a cluster, POTA, SOTA etc. This will be introduced in a future version.
|
||||||
|
operationId: spot
|
||||||
|
parameters:
|
||||||
|
- name: spot
|
||||||
|
description: The spot data to post
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type:
|
||||||
|
$ref: '#/components/schemas/Spot'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Success
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example: "OK"
|
||||||
|
'422':
|
||||||
|
description: Validation error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example: "Failed"
|
||||||
|
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
Spot:
|
Spot:
|
||||||
|
|||||||
Reference in New Issue
Block a user