server alive
This commit is contained in:
parent
1c17b57d8a
commit
fab0e979d5
11 changed files with 353 additions and 28 deletions
49
oedb/resources/root.py
Normal file
49
oedb/resources/root.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
"""
|
||||
Root resource for the OpenEventDatabase.
|
||||
"""
|
||||
|
||||
import falcon
|
||||
from oedb.utils.serialization import dumps
|
||||
from oedb.utils.logging import logger
|
||||
|
||||
class RootResource:
|
||||
"""
|
||||
Resource for the root endpoint.
|
||||
Handles the / endpoint.
|
||||
"""
|
||||
|
||||
def on_get(self, req, resp):
|
||||
"""
|
||||
Handle GET requests to the / endpoint.
|
||||
Returns a JSON response with available routes and a welcome message.
|
||||
|
||||
Args:
|
||||
req: The request object.
|
||||
resp: The response object.
|
||||
"""
|
||||
logger.info("Processing GET request to /")
|
||||
|
||||
try:
|
||||
# Create a response with available routes and a welcome message
|
||||
response = {
|
||||
"message": "Welcome to the OpenEventDatabase API!",
|
||||
"available_routes": {
|
||||
"/": "This endpoint - provides information about available routes",
|
||||
"/event": "Get events matching specified criteria",
|
||||
"/event/{id}": "Get a specific event by ID",
|
||||
"/event/search": "Search for events using a GeoJSON geometry",
|
||||
"/stats": "Get statistics about the database"
|
||||
}
|
||||
}
|
||||
|
||||
# Set the response body and status
|
||||
resp.text = dumps(response)
|
||||
resp.status = falcon.HTTP_200
|
||||
logger.success("Successfully processed GET request to /")
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing GET request to /: {e}")
|
||||
resp.status = falcon.HTTP_500
|
||||
resp.text = dumps({"error": str(e)})
|
||||
|
||||
# Create a global instance of RootResource
|
||||
root = RootResource()
|
Loading…
Add table
Add a link
Reference in a new issue