-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
32 lines (25 loc) · 839 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os,MySQLdb,sys
from django.http import HttpResponse, Http404
from django.template import Context
from django.template.loader import get_template
from django.shortcuts import render_to_response
db=MySQLdb.connect(user="root",passwd="123456",db="test")
c=db.cursor()
i=0
d={}
while(i<100):
l=[]
c.execute("select matchId from result where jobId=%s;"%i)
while(a=c.fetchone()):
b=list(a)
for i in b:
if i!=-1:
l.append(getThumbImg(i))
d[i]=l
def getThumbImg(itemId):
id=(9-len(str(itemId)))*'0'+str(itemId)
ids=id[0:3]+'/'+id[3:6]+'/'+id[6:]+'/'
imgurl="http://i2.tdimg.com/"+ids+"p.jpg"
return imgurl
def main_page(request):
return render_to_response("main.html",{'matchResultList',d})