Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
f4da767b
authored
2022-06-16 11:28:30 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add Go
1 parent
d204dc5f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
src/apps/doc/go_urls.py
src/apps/doc/views.py
src/apps/urls.py
src/apps/doc/go_urls.py
0 → 100644
View file @
f4da767
from
django.urls
import
path
from
.
import
views
urlpatterns
=
[
path
(
r'v1'
,
views
.
GoView
.
as_view
()),
]
src/apps/doc/views.py
View file @
f4da767
...
...
@@ -6,6 +6,7 @@ import random
import
datetime
import
fitz
import
shutil
import
requests
from
openpyxl
import
Workbook
from
django.utils
import
timezone
# from django.http import HttpResponse
...
...
@@ -67,6 +68,10 @@ def load_data(request, schema):
return
request
.
data
go_args
=
{
'image'
:
fields
.
Raw
(
required
=
True
),
}
usedcar_args
=
{
'vinNo'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
128
)),
"manufactureDate"
:
CustomDate
(
required
=
True
),
...
...
@@ -1496,3 +1501,22 @@ class MPOSView(GenericView, MPOSHandler):
result_list
.
extend
(
result
)
return
response
.
ok
(
data
=
result_list
)
class
GoView
(
GenericView
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
@use_args
(
go_args
,
location
=
'files'
)
def
post
(
self
,
request
,
args
):
files
=
[
(
'img'
,
(
'file'
,
args
.
get
(
'image'
),
'application/octet-stream'
))
]
go_result
=
requests
.
post
(
url
=
conf
.
GO_OCR_URL
,
files
=
files
)
if
go_result
.
status_code
==
200
:
result
=
go_result
.
json
()
.
get
(
'data'
,
''
)
return
response
.
ok
(
data
=
result
)
else
:
return
response
.
res_content
(
3
,
'识别错误'
,
data
=
None
)
...
...
src/apps/urls.py
View file @
f4da767
...
...
@@ -26,5 +26,6 @@ urlpatterns = [
path
(
r'api/compare/'
,
include
(
'apps.doc.compare_urls'
)),
path
(
r'api/doc/'
,
include
(
'apps.doc.internal_urls'
)),
path
(
r'api/mpos/'
,
include
(
'apps.doc.mpos_urls'
)),
path
(
r'api/go/'
,
include
(
'apps.doc.go_urls'
)),
path
(
'api/oauth/'
,
include
(
'oauth2_provider.urls'
,
namespace
=
'oauth2_provider'
)),
]
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment