Python论坛  - 讨论区

标题:[python-chinese] django里面做验证码应用,出了点小问题!

2007年11月27日 星期二 03:15

List shell.lists在gmail.com
星期二 十一月 27 03:15:03 HKT 2007

ÓÃpython+djangoÀ´×ö¸öСÏîÄ¿,¸ãÁ˸öÑéÖ¤Âë,·ÀÖ¹»úÆ÷ÈËÌá½»

a.py

#!/usr/bin/python
#coding=cp936
import Image,ImageDraw,ImageFont 
from django.http import HttpResponse
from django.shortcuts import render_to_response

def index(request):
     m=Image.new('RGB',(50,30),(255,255,255))
     d=ImageDraw.Draw(m) 
     ft=ImageFont.truetype("c:\\windows\\Fonts\\simsun.ttc",18)
     text="123" 
     d.text((5,5),text,fill=(255,0,0),font=ft)
     return m.show()

urls˕̾:
(r'^a/$','a.index')

ÏÖÔÚÎÒÓÃhttp://127.0.0.1/a ·ÃÎʵĻ°, Ö±½ÓÓÃͼƬÆ÷´ò¿ªÍ¼Æ¬ÁË.

ÎÒµÄÎÊÌâÊÇ: 
ÎÒÔõô°ÑÕâ¸öͼƬŪµ½HTMLÀïÃæÈ¥

http://127.0.0.1/a"> ÕâÑù¾Í¿ÉÒÔÒýÓÃͼƬÁË..
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071127/752543ef/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月27日 星期二 08:52

大郎 iexper在gmail.com
星期二 十一月 27 08:52:15 HKT 2007

Ó¦¸ÃÒª¸Ä±äÊä³öhttpÍ·, ÀàËÆÓÚ response.header('plain/jpg')
ÄãÔÚdjangoÎĵµÖÐÕÒÕÒ¿´ :)

On Nov 27, 2007 3:15 AM, List <shell.lists在gmail.com> wrote:

>  ÓÃpython+djangoÀ´×ö¸öСÏîÄ¿,¸ãÁ˸öÑéÖ¤Âë,·ÀÖ¹»úÆ÷ÈËÌá½»
>
> a.py
>
> #!/usr/bin/python
> #coding=cp936
> import Image,ImageDraw,ImageFont
> from django.http import HttpResponse
> from django.shortcuts import render_to_response
>
> def index(request):
>      m=Image.new('RGB',(50,30),(255,255,255))
>      d=ImageDraw.Draw(m)
>      ft=ImageFont.truetype("c:\\windows\\Fonts\\simsun.ttc",18)
>      text="123"
>      d.text((5,5),text,fill=(255,0,0),font=ft)
>      return m.show()
>
> urls˕̾:
> (r'^a/$','a.index')
>
> ÏÖÔÚÎÒÓÃhttp://127.0.0.1/a ·ÃÎʵĻ°, Ö±½ÓÓÃͼƬÆ÷´ò¿ªÍ¼Æ¬ÁË.
>
> ÎÒµÄÎÊÌâÊÇ:
> ÎÒÔõô°ÑÕâ¸öͼƬŪµ½HTMLÀïÃæÈ¥
>
> http://127.0.0.1/a"> ÕâÑù¾Í¿ÉÒÔÒýÓÃͼƬÁË..
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
×îºÃµÄÍƹã±ãÊÇʵ¼ÊÓ¦ÓÃ
×î½üÔÚѧϰweb.py, ¼á³Ö²ÅÄܽø²½
http://del.icio.us/iexper
http://twitter.com/qichangxing
Gtalk: iexper(at)gmail.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071127/8432e6a2/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月27日 星期二 10:26

leopay leopay在gmail.com
星期二 十一月 27 10:26:49 HKT 2007

¹¹Ôì¸öbuf£¬°ÑÉú³ÉµÄͼƬsaveµ½ÀïÃ棬Ȼºó·µ»Øʱָ¶¨httpÍ·
buf = cStringIO.StringIO()
m.save(buf, 'PNG')
return HttpResponse(buf.getvalue(),'image/PNG')

On 11/27/07, List <shell.lists在gmail.com> wrote:
>
>  ÓÃpython+djangoÀ´×ö¸öСÏîÄ¿,¸ãÁ˸öÑéÖ¤Âë,·ÀÖ¹»úÆ÷ÈËÌá½»
>
> a.py
>
> #!/usr/bin/python
> #coding=cp936
> import Image,ImageDraw,ImageFont
> from django.http import HttpResponse
> from django.shortcuts import render_to_response
>
> def index(request):
>      m=Image.new('RGB',(50,30),(255,255,255))
>      d=ImageDraw.Draw(m)
>      ft=ImageFont.truetype("c:\\windows\\Fonts\\simsun.ttc",18)
>      text="123"
>      d.text((5,5),text,fill=(255,0,0),font=ft)
>      return m.show()
>
> urls˕̾:
> (r'^a/$','a.index')
>
> ÏÖÔÚÎÒÓÃhttp://127.0.0.1/a ·ÃÎʵĻ°, Ö±½ÓÓÃͼƬÆ÷´ò¿ªÍ¼Æ¬ÁË.
>
> ÎÒµÄÎÊÌâÊÇ:
> ÎÒÔõô°ÑÕâ¸öͼƬŪµ½HTMLÀïÃæÈ¥
>
> http://127.0.0.1/a"> ÕâÑù¾Í¿ÉÒÔÒýÓÃͼƬÁË..
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071127/27edf5b2/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月27日 星期二 10:46

@@ askfor在gmail.com
星期二 十一月 27 10:46:37 HKT 2007

ÏÖÔÚ²»ÊÇÓлشð¼òµ¥µÄËãÊõÎÊÌâµÄÑéÖ¤·½Ê½Âð£¬ÕâÖÖÓ¦¸Ã±È½Ï·½±ã

On 11/27/07, leopay <leopay在gmail.com> wrote:
>
> ¹¹Ôì¸öbuf£¬°ÑÉú³ÉµÄͼƬsaveµ½ÀïÃ棬Ȼºó·µ»Øʱָ¶¨httpÍ·
> buf = cStringIO.StringIO()
> m.save(buf, 'PNG')
> return HttpResponse(buf.getvalue(),'image/PNG')
>
>  On 11/27/07, List <shell.lists在gmail.com> wrote:
>
> >  ÓÃpython+djangoÀ´×ö¸öСÏîÄ¿,¸ãÁ˸öÑéÖ¤Âë,·ÀÖ¹»úÆ÷ÈËÌá½»
> >
> > a.py
> >
> > #!/usr/bin/python
> > #coding=cp936
> > import Image,ImageDraw,ImageFont
> > from django.http import HttpResponse
> > from django.shortcuts import render_to_response
> >
> > def index(request):
> >      m=Image.new('RGB',(50,30),(255,255,255))
> >      d=ImageDraw.Draw(m)
> >      ft=ImageFont.truetype("c:\\windows\\Fonts\\simsun.ttc",18)
> >      text="123"
> >      d.text((5,5),text,fill=(255,0,0),font=ft)
> >      return m.show()
> >
> > urls˕̾:
> > (r'^a/$','a.index')
> >
> > ÏÖÔÚÎÒÓÃhttp://127.0.0.1/a ·ÃÎʵĻ°, Ö±½ÓÓÃͼƬÆ÷´ò¿ªÍ¼Æ¬ÁË.
> >
> > ÎÒµÄÎÊÌâÊÇ:
> > ÎÒÔõô°ÑÕâ¸öͼƬŪµ½HTMLÀïÃæÈ¥
> >
> > http://127.0.0.1/a"> ÕâÑù¾Í¿ÉÒÔÒýÓÃͼƬÁË..
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> >
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071127/53fa196d/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月27日 星期二 10:51

大郎 iexper在gmail.com
星期二 十一月 27 10:51:35 HKT 2007

ÔÚrobert chenµÄ·½°¸ÖÐ, ÊÇÉú³ÉÁË´óÁ¿Ëæ»úµÄÑéÖ¤Âëͼ, ʹÓÃʱֱ½Óµ÷ÓÃ, ¶ø²»ÊÇʵʱÉú³É.

On Nov 27, 2007 10:46 AM, @@ <askfor在gmail.com> wrote:

> ÏÖÔÚ²»ÊÇÓлشð¼òµ¥µÄËãÊõÎÊÌâµÄÑéÖ¤·½Ê½Âð£¬ÕâÖÖÓ¦¸Ã±È½Ï·½±ã
>
> On 11/27/07, leopay <leopay在gmail.com> wrote:
>
> > ¹¹Ôì¸öbuf£¬°ÑÉú³ÉµÄͼƬsaveµ½ÀïÃ棬Ȼºó·µ»Øʱָ¶¨httpÍ·
> > buf = cStringIO.StringIO()
> > m.save(buf, 'PNG')
> > return HttpResponse(buf.getvalue(),'image/PNG')
> >
> >  On 11/27/07, List < shell.lists在gmail.com> wrote:
> >
> > >  ÓÃpython+djangoÀ´×ö¸öСÏîÄ¿,¸ãÁ˸öÑéÖ¤Âë,·ÀÖ¹»úÆ÷ÈËÌá½»
> > >
> > > a.py
> > >
> > > #!/usr/bin/python
> > > #coding=cp936
> > > import Image,ImageDraw,ImageFont
> > > from django.http import HttpResponse
> > > from django.shortcuts import render_to_response
> > >
> > > def index(request):
> > >      m=Image.new('RGB',(50,30),(255,255,255))
> > >      d=ImageDraw.Draw(m)
> > >      ft=ImageFont.truetype("c:\\windows\\Fonts\\simsun.ttc",18)
> > >      text="123"
> > >      d.text((5,5),text,fill=(255,0,0),font=ft)
> > >      return m.show()
> > >
> > > urls˕̾:
> > > (r'^a/$','a.index')
> > >
> > > ÏÖÔÚÎÒÓÃhttp://127.0.0.1/a ·ÃÎʵĻ°, Ö±½ÓÓÃͼƬÆ÷´ò¿ªÍ¼Æ¬ÁË.
> > >
> > > ÎÒµÄÎÊÌâÊÇ:
> > > ÎÒÔõô°ÑÕâ¸öͼƬŪµ½HTMLÀïÃæÈ¥
> > >
> > > http://127.0.0.1/a"> ÕâÑù¾Í¿ÉÒÔÒýÓÃͼƬÁË..
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
×îºÃµÄÍƹã±ãÊÇʵ¼ÊÓ¦ÓÃ
×î½üÔÚѧϰweb.py, ¼á³Ö²ÅÄܽø²½
http://del.icio.us/iexper
http://twitter.com/qichangxing
Gtalk: iexper(at)gmail.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071127/bbd4ac1c/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月27日 星期二 15:45

List shell.lists在gmail.com
星期二 十一月 27 15:45:51 HKT 2007

THX,  °´ÕÕÄãµÄ·½·¨, ¸ã¶¨  .. ~   ¸Ðл .!
  ----- Original Message ----- 
  From: leopay 
  To: python-chinese在lists.python.cn 
  Sent: Tuesday, November 27, 2007 10:26 AM
  Subject: Re: [python-chinese]djangoÀïÃæ×öÑéÖ¤ÂëÓ¦ÓÃ,³öÁ˵ãСÎÊÌâ!


  ¹¹Ôì¸öbuf£¬°ÑÉú³ÉµÄͼƬsaveµ½ÀïÃ棬Ȼºó·µ»Øʱָ¶¨httpÍ·
  buf = cStringIO.StringIO()
  m.save(buf, 'PNG')
  return HttpResponse(buf.getvalue(),'image/PNG')
   
  On 11/27/07, List <shell.lists在gmail.com> wrote: 
    ÓÃpython+djangoÀ´×ö¸öСÏîÄ¿,¸ãÁ˸öÑéÖ¤Âë,·ÀÖ¹»úÆ÷ÈËÌá½»

    a.py

    #!/usr/bin/python
    #coding=cp936
    import Image,ImageDraw,ImageFont 
    from django.http import HttpResponse
    from django.shortcuts import render_to_response

    def index(request):
         m=Image.new('RGB',(50,30),(255,255,255))
         d=ImageDraw.Draw(m) 
         ft=ImageFont.truetype("c:\\windows\\Fonts\\simsun.ttc",18)
         text="123"  
         d.text((5,5),text,fill=(255,0,0),font=ft)
         return m.show()

    urls˕̾:
    (r'^a/$','a.index')

    ÏÖÔÚÎÒÓÃhttp://127.0.0.1/a ·ÃÎʵĻ°, Ö±½ÓÓÃͼƬÆ÷´ò¿ªÍ¼Æ¬ÁË.

    ÎÒµÄÎÊÌâÊÇ: 
    ÎÒÔõô°ÑÕâ¸öͼƬŪµ½HTMLÀïÃæÈ¥

    http://127.0.0.1/a"> ÕâÑù¾Í¿ÉÒÔÒýÓÃͼƬÁË..

    _______________________________________________ 
    python-chinese
    Post: send python-chinese在lists.python.cn
    Subscribe: send subscribe to python-chinese-request在lists.python.cn
    Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn 
    Detail Info: http://python.cn/mailman/listinfo/python-chinese





------------------------------------------------------------------------------


  _______________________________________________
  python-chinese
  Post: send python-chinese在lists.python.cn
  Subscribe: send subscribe to python-chinese-request在lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20071127/ad07982b/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号