Up API
Browse files- .gitignore +1 -0
- Dockerfile +11 -0
- main.py +50 -0
- mocks/data.json +137 -0
- mocks/parking.json +147 -0
- routes/__init__.py +1 -0
- routes/__pycache__/__init__.cpython-311.pyc +0 -0
- routes/api/__init__.py +1 -0
- routes/api/__pycache__/__init__.cpython-311.pyc +0 -0
- routes/api/__pycache__/free_places.cpython-311.pyc +0 -0
- routes/api/free_places.py +46 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
env_smart
|
Dockerfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from debian:12.11
|
| 2 |
+
|
| 3 |
+
RUN apt -y updat
|
| 4 |
+
|
| 5 |
+
RUN apt-get install python3-pip
|
| 6 |
+
RUN python3 --version
|
| 7 |
+
RUN pip --version
|
| 8 |
+
|
| 9 |
+
RUN echo "[SERVER WORK ONLINE]" > keepalive.log
|
| 10 |
+
|
| 11 |
+
CMD tail -f keepalive.log
|
main.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
@app.get("/")
|
| 7 |
+
async def root():
|
| 8 |
+
return {"message": "Api funcionando"}
|
| 9 |
+
|
| 10 |
+
@app.get("/free_places")
|
| 11 |
+
async def read_park():
|
| 12 |
+
with open('mocks/data.json', 'r', encoding='utf-8') as f:
|
| 13 |
+
free_places = json.load(f)
|
| 14 |
+
|
| 15 |
+
return free_places
|
| 16 |
+
|
| 17 |
+
@app.get("/free_places/public")
|
| 18 |
+
async def read_public_places():
|
| 19 |
+
with open('mocks/data.json', 'r', encoding='utf-8') as f:
|
| 20 |
+
free_places = json.load(f)
|
| 21 |
+
|
| 22 |
+
info = free_places["info"]
|
| 23 |
+
public_places = free_places["data"]["free_publics_places"]
|
| 24 |
+
|
| 25 |
+
return {"info":info, "places": public_places}
|
| 26 |
+
|
| 27 |
+
@app.get("/free_places/parking")
|
| 28 |
+
async def read_parking():
|
| 29 |
+
with open('mocks/data.json', 'r', encoding='utf-8') as f:
|
| 30 |
+
free_places = json.load(f)
|
| 31 |
+
|
| 32 |
+
info = free_places["info"]
|
| 33 |
+
public_places = free_places["data"]["parkings"]
|
| 34 |
+
|
| 35 |
+
return {"info":info, "parking": public_places}
|
| 36 |
+
|
| 37 |
+
@app.get("/free_places/parking/{id_parking}")
|
| 38 |
+
async def read_places_parking(id_parking):
|
| 39 |
+
with open('mocks/parking.json', 'r', encoding='utf-8') as f:
|
| 40 |
+
data_park = json.load(f)
|
| 41 |
+
|
| 42 |
+
info = data_park["info"]
|
| 43 |
+
data = None
|
| 44 |
+
id_parking = int(id_parking)
|
| 45 |
+
|
| 46 |
+
for park in data_park["parkings"]:
|
| 47 |
+
if park["id_"] == id_parking:
|
| 48 |
+
data = park
|
| 49 |
+
|
| 50 |
+
return {"info":info, "data":data}
|
mocks/data.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"info": {
|
| 3 |
+
"date_consult": "12-03-2025",
|
| 4 |
+
"total": 2
|
| 5 |
+
},
|
| 6 |
+
"data": {
|
| 7 |
+
"free_publics_places": [
|
| 8 |
+
{
|
| 9 |
+
"latitude": 18.84541984430001,
|
| 10 |
+
"length": -97.11032816912395,
|
| 11 |
+
"position": {
|
| 12 |
+
"street": "Sur 12",
|
| 13 |
+
"street_down": "Pte. 3",
|
| 14 |
+
"street_up": "Pte. 5"
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"latitude": 18.845140570426114,
|
| 19 |
+
"length": -97.11021417699786,
|
| 20 |
+
"position": {
|
| 21 |
+
"street": "Sur 12",
|
| 22 |
+
"street_down": "Pte. 3",
|
| 23 |
+
"street_up": "Pte. 5"
|
| 24 |
+
}
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"latitude": 18.845116036395773,
|
| 28 |
+
"length": -97.11020045286234,
|
| 29 |
+
"position": {
|
| 30 |
+
"street": "Sur 12",
|
| 31 |
+
"street_down": "Pte. 3",
|
| 32 |
+
"street_up": "Pte. 5"
|
| 33 |
+
}
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"latitude": 18.845078594550323,
|
| 37 |
+
"length": -97.11018637126399,
|
| 38 |
+
"position": {
|
| 39 |
+
"street": "Sur 12",
|
| 40 |
+
"street_down": "Pte. 3",
|
| 41 |
+
"street_up": "Pte. 5"
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"latitude": 18.84493580777145,
|
| 46 |
+
"length": -97.11013071542224,
|
| 47 |
+
"position": {
|
| 48 |
+
"street": "Sur 12",
|
| 49 |
+
"street_down": "Pte. 3",
|
| 50 |
+
"street_up": "Pte. 5"
|
| 51 |
+
}
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"latitude": 18.84756953779409,
|
| 55 |
+
"length": -97.11028781254234,
|
| 56 |
+
"position": {
|
| 57 |
+
"street": "Nte. 11",
|
| 58 |
+
"street_down": "Colon Poniente",
|
| 59 |
+
"street_up": "Pte. 2"
|
| 60 |
+
}
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"latitude": 18.847367679597486,
|
| 64 |
+
"length": -97.11020153605836,
|
| 65 |
+
"position": {
|
| 66 |
+
"street": "Nte. 11",
|
| 67 |
+
"street_down": "Colon Poniente",
|
| 68 |
+
"street_up": "Pte. 2"
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"latitude": 18.84717375941359,
|
| 73 |
+
"length": -97.11012125099623,
|
| 74 |
+
"position": {
|
| 75 |
+
"street": "Nte. 11",
|
| 76 |
+
"street_down": "Colon Poniente",
|
| 77 |
+
"street_up": "Pte. 2"
|
| 78 |
+
}
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"latitude": 18.847076232221127,
|
| 82 |
+
"length": -97.11007931103883,
|
| 83 |
+
"position": {
|
| 84 |
+
"street": "Nte. 11",
|
| 85 |
+
"street_down": "Colon Poniente",
|
| 86 |
+
"street_up": "Pte. 2"
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
],
|
| 90 |
+
"parkings": [
|
| 91 |
+
{
|
| 92 |
+
"id_": 123456,
|
| 93 |
+
"name": "Automotriz Gochicoa",
|
| 94 |
+
"latitude": 18.844533992770028,
|
| 95 |
+
"length": -97.1088492028291,
|
| 96 |
+
"position": {
|
| 97 |
+
"street": "Sur 10",
|
| 98 |
+
"street_down": "Pte. 7",
|
| 99 |
+
"street_up": "Pte. 5"
|
| 100 |
+
}
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"id_": 123457,
|
| 104 |
+
"name": "Estacionamiento San José",
|
| 105 |
+
"latitude": 18.846126078544266,
|
| 106 |
+
"length": -97.10859196597018,
|
| 107 |
+
"position": {
|
| 108 |
+
"street": "Sur 8",
|
| 109 |
+
"street_down": "Pte. 5",
|
| 110 |
+
"street_up": "Pte. 3"
|
| 111 |
+
}
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"id_": 123458,
|
| 115 |
+
"name": "Estacionamiento Público Sur 2",
|
| 116 |
+
"latitude": 18.84753838296079,
|
| 117 |
+
"length": -97.1062655386729,
|
| 118 |
+
"position": {
|
| 119 |
+
"street": "Sur 2",
|
| 120 |
+
"street_down": "Pte. 3",
|
| 121 |
+
"street_up": "Colon Poniente"
|
| 122 |
+
}
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"id_": 123459,
|
| 126 |
+
"name": "Estacionamiento orizaba",
|
| 127 |
+
"latitude": 18.849334164191912,
|
| 128 |
+
"length": -97.10858578936457,
|
| 129 |
+
"position": {
|
| 130 |
+
"street": "Pte. 4",
|
| 131 |
+
"street_down": "Nte. 7",
|
| 132 |
+
"street_up": "Paseo del rio Orizaba"
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
]
|
| 136 |
+
}
|
| 137 |
+
}
|
mocks/parking.json
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"info": {
|
| 3 |
+
"date_consult": "12-03-2025",
|
| 4 |
+
"total": 2
|
| 5 |
+
},
|
| 6 |
+
"parkings": [
|
| 7 |
+
{
|
| 8 |
+
"id_": 123456,
|
| 9 |
+
"name": "Automotriz Gochicoa",
|
| 10 |
+
"latitude": 18.844533992770028,
|
| 11 |
+
"length": -97.1088492028291,
|
| 12 |
+
"avenue": null,
|
| 13 |
+
"street": "Sur 10",
|
| 14 |
+
"free_private_place": [
|
| 15 |
+
{
|
| 16 |
+
"id_": 456789,
|
| 17 |
+
"code": "ER1",
|
| 18 |
+
"free": true
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"id_": 456790,
|
| 22 |
+
"code": "ER2",
|
| 23 |
+
"free": true
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"id_": 456791,
|
| 27 |
+
"code": "ER3",
|
| 28 |
+
"free": true
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"id_": 456792,
|
| 32 |
+
"code": "ER4",
|
| 33 |
+
"free": true
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"id_": 456793,
|
| 37 |
+
"code": "ER5",
|
| 38 |
+
"free": true
|
| 39 |
+
}
|
| 40 |
+
]
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"id_": 123457,
|
| 44 |
+
"name": "Estacionamiento San José",
|
| 45 |
+
"latitude": 18.846126078544266,
|
| 46 |
+
"length": -97.10859196597018,
|
| 47 |
+
"position": {
|
| 48 |
+
"street": "Sur 8",
|
| 49 |
+
"street_down": "Pte. 5",
|
| 50 |
+
"street_up": "Pte. 3"
|
| 51 |
+
},
|
| 52 |
+
"free_private_place": [
|
| 53 |
+
{
|
| 54 |
+
"id_": 456793,
|
| 55 |
+
"code": "PR5",
|
| 56 |
+
"free": true
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"id_": 456794,
|
| 60 |
+
"code": "PR6",
|
| 61 |
+
"free": true
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"id_": 456795,
|
| 65 |
+
"code": "PR7",
|
| 66 |
+
"free": true
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"id_": 456796,
|
| 70 |
+
"code": "PR8",
|
| 71 |
+
"free": true
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"id_": 456797,
|
| 75 |
+
"code": "PR9",
|
| 76 |
+
"free": true
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"id_": 456798,
|
| 80 |
+
"code": "PR10",
|
| 81 |
+
"free": true
|
| 82 |
+
}
|
| 83 |
+
]
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"id_": 123458,
|
| 87 |
+
"name": "Estacionamiento Público Sur 2",
|
| 88 |
+
"latitude": 18.84753838296079,
|
| 89 |
+
"length": -97.1062655386729,
|
| 90 |
+
"position": {
|
| 91 |
+
"street": "Sur 2",
|
| 92 |
+
"street_down": "Pte. 3",
|
| 93 |
+
"street_up": "Colon Poniente"
|
| 94 |
+
},
|
| 95 |
+
"free_private_place": [
|
| 96 |
+
{
|
| 97 |
+
"id_": 456799,
|
| 98 |
+
"code": "PL1",
|
| 99 |
+
"free": true
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"id_": 456800,
|
| 103 |
+
"code": "PL12",
|
| 104 |
+
"free": true
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"id_": 456801,
|
| 108 |
+
"code": "PL15",
|
| 109 |
+
"free": true
|
| 110 |
+
}
|
| 111 |
+
]
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"id_": 123459,
|
| 115 |
+
"name": "Estacionamiento orizaba",
|
| 116 |
+
"latitude": 18.849334164191912,
|
| 117 |
+
"length": -97.10858578936457,
|
| 118 |
+
"position": {
|
| 119 |
+
"street": "Pte. 4",
|
| 120 |
+
"street_down": "Nte. 7",
|
| 121 |
+
"street_up": "Paseo del rio Orizaba"
|
| 122 |
+
},
|
| 123 |
+
"free_private_place": [
|
| 124 |
+
{
|
| 125 |
+
"id_": 456802,
|
| 126 |
+
"code": "TO10",
|
| 127 |
+
"free": true
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"id_": 456803,
|
| 131 |
+
"code": "TO11",
|
| 132 |
+
"free": true
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"id_": 456804,
|
| 136 |
+
"code": "TO12",
|
| 137 |
+
"free": true
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"id_": 456805,
|
| 141 |
+
"code": "TO13",
|
| 142 |
+
"free": true
|
| 143 |
+
}
|
| 144 |
+
]
|
| 145 |
+
}
|
| 146 |
+
]
|
| 147 |
+
}
|
routes/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from .api import router
|
routes/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (228 Bytes). View file
|
|
|
routes/api/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from .free_places import router
|
routes/api/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (240 Bytes). View file
|
|
|
routes/api/__pycache__/free_places.cpython-311.pyc
ADDED
|
Binary file (2.95 kB). View file
|
|
|
routes/api/free_places.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
router = APIRouter()
|
| 5 |
+
|
| 6 |
+
@router.get("/free_places")
|
| 7 |
+
async def read_park():
|
| 8 |
+
with open('../mocks/data.json', 'r', encoding='utf-8') as f:
|
| 9 |
+
free_places = json.load(f)
|
| 10 |
+
|
| 11 |
+
return free_places
|
| 12 |
+
|
| 13 |
+
@router.get("/free_places/public")
|
| 14 |
+
async def read_public_places():
|
| 15 |
+
with open('../mocks/data.json', 'r', encoding='utf-8') as f:
|
| 16 |
+
free_places = json.load(f)
|
| 17 |
+
|
| 18 |
+
info = free_places["info"]
|
| 19 |
+
public_places = free_places["data"]["free_publics_places"]
|
| 20 |
+
|
| 21 |
+
return {"info":info, "places": public_places}
|
| 22 |
+
|
| 23 |
+
@router.get("/free_places/parking")
|
| 24 |
+
async def read_parking():
|
| 25 |
+
with open('../mocks/data.json', 'r', encoding='utf-8') as f:
|
| 26 |
+
free_places = json.load(f)
|
| 27 |
+
|
| 28 |
+
info = free_places["info"]
|
| 29 |
+
public_places = free_places["data"]["parkings"]
|
| 30 |
+
|
| 31 |
+
return {"info":info, "parking": public_places}
|
| 32 |
+
|
| 33 |
+
@router.get("/free_places/parking/{id_parking}")
|
| 34 |
+
async def read_places_parking(id_parking):
|
| 35 |
+
with open('../mocks/parking.json', 'r', encoding='utf-8') as f:
|
| 36 |
+
data_park = json.load(f)
|
| 37 |
+
|
| 38 |
+
info = data_park["info"]
|
| 39 |
+
data = None
|
| 40 |
+
id_parking = int(id_parking)
|
| 41 |
+
|
| 42 |
+
for park in data_park["parkings"]:
|
| 43 |
+
if park["id_"] == id_parking:
|
| 44 |
+
data = park
|
| 45 |
+
|
| 46 |
+
return {"info":info, "data":data}
|