mirror of
https://github.com/its-michaelroy/Deep-Impact.git
synced 2026-06-04 02:20:41 +00:00
Cleaned up proj directory by removing extra proj dir, updated defenses, effects, and main page with new formatting for better appearance
This commit is contained in:
0
backend/api_app/__init__.py
Normal file
0
backend/api_app/__init__.py
Normal file
3
backend/api_app/admin.py
Normal file
3
backend/api_app/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
backend/api_app/apps.py
Normal file
6
backend/api_app/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiAppConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'api_app'
|
||||
0
backend/api_app/migrations/__init__.py
Normal file
0
backend/api_app/migrations/__init__.py
Normal file
3
backend/api_app/models.py
Normal file
3
backend/api_app/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
3
backend/api_app/tests.py
Normal file
3
backend/api_app/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
9
backend/api_app/urls.py
Normal file
9
backend/api_app/urls.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
from .views import Sentry, OpenAI
|
||||
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('sentry/', Sentry.as_view(), name='sentry'),
|
||||
path('openai/', OpenAI.as_view(), name='openai'),
|
||||
]
|
||||
23
backend/api_app/utils.py
Normal file
23
backend/api_app/utils.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
import os
|
||||
import requests
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.status import (
|
||||
HTTP_200_OK,
|
||||
HTTP_204_NO_CONTENT,
|
||||
HTTP_201_CREATED,
|
||||
HTTP_400_BAD_REQUEST
|
||||
)
|
||||
|
||||
|
||||
sentry_api_key = os.environ.get("SENTRY_API_KEY")
|
||||
|
||||
def get_sentry():
|
||||
try:
|
||||
response = requests.get(f'https://api.nasa.gov/neo/rest/v1/neo/browse?api_key={sentry_api_key}')
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
return Response(data, status=HTTP_200_OK)
|
||||
except ValidationError as e:
|
||||
print(e)
|
||||
return Response(e, status=HTTP_400_BAD_REQUEST)
|
||||
26
backend/api_app/views.py
Normal file
26
backend/api_app/views.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from django.shortcuts import render
|
||||
from django.core.exceptions import ValidationError
|
||||
import os
|
||||
import requests
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.status import (
|
||||
HTTP_200_OK,
|
||||
HTTP_204_NO_CONTENT,
|
||||
HTTP_201_CREATED,
|
||||
HTTP_400_BAD_REQUEST
|
||||
)
|
||||
from .utils import get_sentry
|
||||
|
||||
sentry_api_key = os.environ.get("SENTRY_API_KEY")
|
||||
|
||||
|
||||
|
||||
# Create your views here.
|
||||
class Sentry(APIView):
|
||||
def get(self, request):
|
||||
return get_sentry()
|
||||
|
||||
|
||||
class OpenAI(APIView):
|
||||
pass
|
||||
Reference in New Issue
Block a user