maps-by-people-api 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maps_by_people_api-0.0.1/LICENSE +19 -0
- maps_by_people_api-0.0.1/PKG-INFO +27 -0
- maps_by_people_api-0.0.1/README.md +11 -0
- maps_by_people_api-0.0.1/pyproject.toml +34 -0
- maps_by_people_api-0.0.1/src/maps_by_people_api/__init__.py +0 -0
- maps_by_people_api-0.0.1/src/maps_by_people_api/app/__init__.py +0 -0
- maps_by_people_api-0.0.1/src/maps_by_people_api/app/main.py +20 -0
- maps_by_people_api-0.0.1/src/maps_by_people_api/app/routers/__init__.py +28 -0
- maps_by_people_api-0.0.1/src/maps_by_people_api/app/routers/places.py +48 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maps-by-people-api
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Maps by People - API
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Author: danialcala94
|
|
7
|
+
Author-email: danielalcalavalera@gmail.com
|
|
8
|
+
Requires-Python: >=3.10,<3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Requires-Dist: fastapi (>=0.124.4,<9999.0.0)
|
|
13
|
+
Requires-Dist: mongobuteasy (>=0.0.1,<1.0.0)
|
|
14
|
+
Requires-Dist: uvicorn (>=0.49.0,<9999.0.0)
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# Maps by People - API
|
|
18
|
+
|
|
19
|
+
The module to provide information about the places we have in our database.
|
|
20
|
+
|
|
21
|
+
## Endpoints
|
|
22
|
+
|
|
23
|
+
#### GET
|
|
24
|
+
No endpoints available
|
|
25
|
+
|
|
26
|
+
#### POST
|
|
27
|
+
No endpoints available
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "maps-by-people-api"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Maps by People - API"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "danialcala94", email = "danielalcalavalera@gmail.com"}
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.10,<3.12"
|
|
10
|
+
|
|
11
|
+
[tool.poetry.dependencies]
|
|
12
|
+
# Mandatory
|
|
13
|
+
fastapi = { version = ">=0.124.4,<9999.0.0", optional = false }
|
|
14
|
+
uvicorn = { version = ">=0.49.0,<9999.0.0", optional = false }
|
|
15
|
+
mongobuteasy = { version = ">=0.0.1,<1.0.0", optional = false }
|
|
16
|
+
# Optional
|
|
17
|
+
|
|
18
|
+
[tool.poetry]
|
|
19
|
+
packages = [{include = "maps_by_people_api", from = "src"}]
|
|
20
|
+
|
|
21
|
+
[tool.poetry.group.dev.dependencies]
|
|
22
|
+
pytest = "^8.3.5"
|
|
23
|
+
httpx = ">=0.28.1"
|
|
24
|
+
yta_testing = ">=0.3.7"
|
|
25
|
+
|
|
26
|
+
[tool.pytest.ini_options]
|
|
27
|
+
markers = [
|
|
28
|
+
"mandatory: mandatory tests for release",
|
|
29
|
+
"additional: exhaustive and demanding tests"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
34
|
+
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from maps_by_people_api.app.routers import router as general_router
|
|
2
|
+
from maps_by_people_api.app.routers.places import router as places_router
|
|
3
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
4
|
+
from fastapi import FastAPI
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
app = FastAPI()
|
|
8
|
+
|
|
9
|
+
# Added for the proxy-image endpoint
|
|
10
|
+
app.add_middleware(
|
|
11
|
+
CORSMiddleware,
|
|
12
|
+
allow_origins=["*"],
|
|
13
|
+
allow_credentials=False,
|
|
14
|
+
allow_methods=["*"],
|
|
15
|
+
allow_headers=["*"],
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Include all the routers we have
|
|
19
|
+
app.include_router(general_router)
|
|
20
|
+
app.include_router(places_router)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from fastapi import APIRouter
|
|
2
|
+
from fastapi.responses import JSONResponse, RedirectResponse
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
PREFIX = f''
|
|
6
|
+
|
|
7
|
+
router = APIRouter(
|
|
8
|
+
prefix = PREFIX
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
@router.get('/')
|
|
12
|
+
def router_index(
|
|
13
|
+
) -> RedirectResponse:
|
|
14
|
+
return RedirectResponse(
|
|
15
|
+
url = "/check-status"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@router.get('/check-status')
|
|
20
|
+
def route_check_status(
|
|
21
|
+
) -> JSONResponse:
|
|
22
|
+
return JSONResponse(
|
|
23
|
+
{
|
|
24
|
+
'error': False,
|
|
25
|
+
'message': 'Hello World!'
|
|
26
|
+
},
|
|
27
|
+
status_code = 200
|
|
28
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from mongobuteasy.handler import MongoDatabaseHandler
|
|
2
|
+
from mongobuteasy.client import MongoDatabaseClient
|
|
3
|
+
from bson import ObjectId
|
|
4
|
+
from fastapi import APIRouter
|
|
5
|
+
from fastapi.responses import JSONResponse
|
|
6
|
+
from fastapi.encoders import jsonable_encoder
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
PREFIX = f'/places'
|
|
10
|
+
|
|
11
|
+
router = APIRouter(
|
|
12
|
+
prefix = PREFIX
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
@router.get('/{place_id}')
|
|
16
|
+
async def get_video(
|
|
17
|
+
place_id: str
|
|
18
|
+
) -> JSONResponse:
|
|
19
|
+
"""
|
|
20
|
+
TODO: This handler must be something that is loaded
|
|
21
|
+
only once and then just reused.
|
|
22
|
+
"""
|
|
23
|
+
handler = MongoDatabaseHandler(
|
|
24
|
+
host = 'localhost:27017',
|
|
25
|
+
database_name = 'maps-by-people',
|
|
26
|
+
client_type = MongoDatabaseClient.LOCAL_MONGODB_COMPASS
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# TODO: This must be received as a param
|
|
30
|
+
place_id = '6a634b2e4507691f798e977c'
|
|
31
|
+
|
|
32
|
+
place = handler.find_one_by_id(
|
|
33
|
+
table_name = 'places',
|
|
34
|
+
id = place_id
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Encode 'ObjectId'
|
|
38
|
+
place = jsonable_encoder(
|
|
39
|
+
place,
|
|
40
|
+
custom_encoder = {
|
|
41
|
+
ObjectId: str
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return JSONResponse(
|
|
46
|
+
content = place,
|
|
47
|
+
status_code = 200
|
|
48
|
+
)
|