-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbase.py
More file actions
24 lines (19 loc) · 800 Bytes
/
base.py
File metadata and controls
24 lines (19 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from rest_framework.decorators import api_view
from rest_framework.response import Response
BASE = "https://api.cannlytics.com"
ENDPOINTS = ["labs"]
VERSION = "v1"
@api_view(["GET"])
def index(request, format=None):
"""Informational base endpoint."""
message = "Welcome to the Cannlytics API."
message += f"The current version is {VERSION} and is located at {BASE}/{VERSION}."
return Response({"data": message}, content_type="application/json")
@api_view(["GET"])
def base(request, format=None):
"""Informational version endpoint."""
message = f"Welcome to {VERSION} of the Cannlytics API."
message += "Available endpoints:\n\n"
for endpoint in ENDPOINTS:
message += f"{endpoint}\n"
return Response({"data": message}, content_type="application/json")