Starlite-Tile38
Showcase using Tile38 via pyle38 in a Starlite application.
Report Bug · Request Feature
Table of Contents
About The Project
Showcase of using Tile38 with Pyle38 in a Starlite application. Can be used as is, or be extended upon with other methods in the pyle38 repertoire of commands.
Built With
Getting Started
Installation
- Clone and install
git clone https://github.com/iwpnd/starlite-tile38.git poetry install
- Setup environment
mv .env.dist .env
- Start your local stack
poe up
- Test it!
poe test
Usage
Once the application is started you can checkout and interact with it via on localhost:8001/schema/redoc.
Or you can use it with http/curl:
Create a vehicle
echo '{ "data": { "type": "Feature", "geometry": {"type": "Point", "coordinates": [13.37, 52.25]}, "properties": {"id": "truck"}}}' \
| http post http://localhost:8001/vehicles
> {data:"type":"Feature","geometry":{"type":"Point","coordinates":[13.37, 52.25]},"properties":{"id":"truck"}}
Get vehicle by id
http get http://localhost:8001/vehicles/truck
> {data:"type":"Feature","geometry":{"type":"Point","coordinates":[13.37, 52.25]},"properties":{"id":"truck"}}
Get all vehicles
http get http://localhost:8001/vehicles
> { data: ["type":"Feature","geometry":{"type": "Point", "coordinates": [13.37, 52.25]},"properties":{"id":"truck"}]}
Get vehicles within radius
http get http://localhost:8001/search?lat=13.37&lon=52.25&radius=1000
> { data: ["type":"Feature","geometry":{"type": "Point", "coordinates": [13.37, 52.25]},"properties":{"id":"truck"}]}
Or you use it with httpx/requests:
import httpx
vehicle = {
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [13.37, 52.25]},
"properties": {"id": "truck"},
}
# store a vehicle
r = httpx.post(
url="http://localhost:8001/vehicles",
json={"data": vehicle}
)
print(r.json())
> { data: ["type":"Feature","geometry":{"type": "Point", "coordinates": [13.37, 52.25]},"properties":{"id":"truck"}]}
# get a vehicle
r = httpx.get(
url="http://localhost:8001/vehicles/truck",
)
print(r.json())
> {"data": {"type":"Feature","geometry": {"coordinates": [13.37,52.25],"type": "Point"},"properties": {"id": "truck"}}}
You get the idea. And can use the rest.
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Benjamin Ramser - @imwithpanda - [email protected]
Project Link: https://github.com/iwpnd/starlite-tile38