-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
118 lines (97 loc) · 2.82 KB
/
main.py
File metadata and controls
118 lines (97 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""
This file is the main file of the application. It is used to run the application or create the JSON data files.
"""
from typing import List
from fastapi import Depends
from fastapi import FastAPI
from import_data.importer import Importer, import_weapons
from models import BlipModel, BlipColor, Marker, PedModel, Weapon
from services import get_blip_colors, get_blip_models, get_markers, get_ped_models, get_weapons
tags_metadata = [
{
"name": "Models",
"description": "Operations with GTA5 models. Retrieve various model data.",
},
]
app = FastAPI(
title="RAGE Data API",
description="An API to access RAGE data such as blip models, colors, markers, ped models, and weapons.",
summary="An API for RAGE data retrieval.",
version="0.1.1",
openapi_tags=tags_metadata,
docs_url="/",
redoc_url="/redoc",
)
@app.get(
"/blip_colors",
tags=["Models"],
summary="Retrieve blip colors data",
description="Fetches and returns the JSON data for blip colors models.",
)
def read_blip_colors(result = Depends(get_blip_colors)) -> List[BlipColor]:
"""
Endpoint to get the blip colors.
"""
return result
@app.get(
"/blip_models",
tags=["Models"],
summary="Retrieve blip models data",
description="Fetches and returns the JSON data for blip models.",
)
def read_blip_models(result = Depends(get_blip_models)) -> List[BlipModel]:
"""
Endpoint to get the blip models.
"""
return result
@app.get(
"/markers",
tags=["Models"],
summary="Retrieve markers data",
description="Fetches and returns the JSON data for markers.",
)
def read_markers(result = Depends(get_markers)) -> List[Marker]:
"""
Endpoint to get the markers.
"""
return result
@app.get(
"/ped_models",
tags=["Models"],
summary="Retrieve ped models data",
description="Fetches and returns the JSON data for ped models.",
)
def read_ped_models(result = Depends(get_ped_models)) -> List[PedModel]:
"""
Endpoint to get the ped models.
"""
return result
@app.get(
"/weapons",
tags=["Models"],
summary="Retrieve weapons data",
description="Fetches and returns the JSON data for weapons models.",
)
def read_weapons(result = Depends(get_weapons)) -> List[Weapon]:
"""
Endpoint to get the weapons.
"""
return result
@app.get(
"/health",
tags=["Health"],
summary="Retrieve the server status",
description="Fetches and returns the JSON data for server status",
)
def health():
"""
Endpoint to get the server status.
"""
return {"status": "ok"}
if __name__ == "__main__":
print("Importing data...")
Importer("blip_models").import_data()
Importer("blip_colors").import_data()
Importer("markers").import_data()
Importer("ped_models").import_data()
import_weapons()