html test uploader

This commit is contained in:
Mohamed Nouffer
2021-12-08 19:13:03 +05:30
parent e5e3f670e9
commit fae9e555dd
4 changed files with 32 additions and 4 deletions

View File

@ -25,7 +25,7 @@ SECRET_KEY = 'django-insecure-#-a9k=#&y3e&a&@%rn7mhl@fk3smxceqh^@1)#9t@c-qzx&k^b
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = ['aiworks.intranet.sumasen.net',] ALLOWED_HOSTS = ['aiworks.intranet.sumasen.net', 'localhost']
# Application definition # Application definition
@ -56,7 +56,7 @@ ROOT_URLCONF = 'ocr.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [

View File

@ -1,7 +1,8 @@
from django.contrib import admin from django.contrib import admin
from django.urls import path, re_path from django.urls import path, re_path
from .views import FileUploadView from .views import FileUploadView, UploaderView
urlpatterns = [ urlpatterns = [
re_path(r'^upload/', FileUploadView.as_view()) re_path(r'^upload/', FileUploadView.as_view()),
path('uploader/', UploaderView, name="uploader")
] ]

View File

@ -1,9 +1,13 @@
from django.shortcuts import render
from rest_framework.views import APIView from rest_framework.views import APIView
from rest_framework.parsers import MultiPartParser from rest_framework.parsers import MultiPartParser
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework import status from rest_framework import status
import easyocr import easyocr
def UploaderView(request):
return render(request, 'sumasen_easyocr/index.html')
class FileUploadView(APIView): class FileUploadView(APIView):
parser_classes = [MultiPartParser,] parser_classes = [MultiPartParser,]

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<style>
html {
font-family: sans-serif;
}
</style>
</head>
<body>
<h2>Sumase OCR file upload test</h2>
<form action="http://aiworks.intranet.sumasen.net:8600/api/v1/upload/" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file_to_upload">
<hr>
<input type="submit" value="Upload To Server" id="upload_file_button">
</form>
</body>
</html>