Skip to content
Snippets Groups Projects
Commit a1ac696a authored by Sustronk, J.J. (Jasper, Student M-CS)'s avatar Sustronk, J.J. (Jasper, Student M-CS)
Browse files

Added transaction api

parent dc5467d9
No related branches found
No related tags found
No related merge requests found
Pipeline #3926 failed
......@@ -37,6 +37,8 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'classifier',
'rest_framework'
]
MIDDLEWARE = [
......@@ -118,3 +120,11 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
]
}
......@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('classifier.urls', namespace='classifier'))
]
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ClassifierConfig(AppConfig):
name = 'classifier'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import TransactionView, TestTransactionView
app_name = "classifier"
urlpatterns = [
path('transaction/<str:tx>', TransactionView.as_view()),
path('transaction/test/<str:tx>', TestTransactionView.as_view())
]
\ No newline at end of file
from django.http import Http404
from rest_framework.response import Response
from rest_framework.permissions import AllowAny
from rest_framework.views import APIView
from bloxplorer import bitcoin_testnet_explorer as test_explorer
from bloxplorer import bitcoin_explorer as explorer
# Create your views here.
class TestTransactionView(APIView):
permission_classes = [AllowAny]
def get(self, request, *args, **kwargs):
try:
return Response(test_explorer.tx.get(kwargs['tx']).data)
except:
raise Http404
class TransactionView(APIView):
permission_classes = [AllowAny]
def get(self, request, *args, **kwargs):
try:
return Response(explorer.tx.get(kwargs['tx']).data)
except:
raise Http404
asgiref==3.3.1
bloxplorer==0.1.9
certifi==2020.12.5
chardet==4.0.0
Django==3.1.7
django-filter==2.4.0
djangorestframework==3.12.2
idna==2.10
Markdown==3.3.4
pytz==2021.1
requests==2.25.1
sqlparse==0.4.1
urllib3==1.26.3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment