Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-tools
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5833d1af
authored
Jun 17, 2022
by
aagusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
output captcha namafile tidak menungjukan isi captcha dan sudah pake .png
1 parent
39e0c731
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
opensipkd/tools/captcha.py
opensipkd/tools/captcha.py
View file @
5833d1a
...
...
@@ -16,10 +16,11 @@ def img_captcha(request, length=5, chars=string.ascii_uppercase + string.digits)
if
not
os
.
path
.
exists
(
captcha_files
):
os
.
makedirs
(
captcha_files
)
file_name
=
get_random_string
(
16
)
+
'.png'
from
pyramid.path
import
AssetResolver
a
=
AssetResolver
(
'opensipkd.base'
)
static_path
=
a
.
resolve
(
'static'
)
.
abspath
()
captcha_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
captcha_files
,
kode_captcha
+
'.png'
))
captcha_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
captcha_files
,
file_name
))
font_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
static_path
,
'v3/fonts/arial.ttf'
))
captcha_image
=
captcha
(
drawings
=
[
background
(
color
=
'#fff'
),
...
...
@@ -34,7 +35,7 @@ def img_captcha(request, length=5, chars=string.ascii_uppercase + string.digits)
image
.
save
(
captcha_path
,
'PNG'
,
quality
=
75
)
kode_captcha
=
kode_captcha
request
.
session
[
'captcha'
]
=
kode_captcha
return
kode_captcha
return
kode_captcha
,
file_name
def
randomcaptcha
(
length
,
chars
=
string
.
ascii_uppercase
+
string
.
digits
):
...
...
@@ -42,6 +43,6 @@ def randomcaptcha(length, chars=string.ascii_uppercase + string.digits):
def
get_captcha
(
request
):
kode_captcha
=
img_captcha
(
request
)
kode_captcha
,
file_name
=
img_captcha
(
request
)
request
.
session
[
'captcha'
]
=
kode_captcha
return
kode_captcha
\ No newline at end of file
return
file_name
Write
Preview
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