-
Notifications
You must be signed in to change notification settings - Fork 0
/
imgServer.py
41 lines (29 loc) · 1.05 KB
/
imgServer.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
33
34
35
36
37
38
39
40
41
import sys,os,re,flask,random
imgDir = "/data_big/meitulu/MeituluCrawler/imgs_old"
app = flask.Flask(__name__)
@app.route('/')
def newone():
imgFile = os.path.join(imgDir, 'gids')
imgList = open(imgFile, 'r').readlines()
imgList = [g.strip().strip('./') for g in imgList]
gid = imgList[random.randint(0,20)]
return flask.redirect('/%s' % gid)
@app.route('/<gid>')
def girlPage(gid):
imgs = []
for (dirPath, dirName, fileNames) in os.walk(os.path.join(imgDir, gid)):
for f in fileNames:
if f.endswith('jpg'):
imgs.append("%s/%s" % (gid, f))
return flask.render_template('meinv.html', imgSrc=imgs)
@app.route('/imgs/<gid>/<file>')
def readImg(gid, file):
with open(os.path.join(imgDir,"%s/%s" % (gid, file)), "rb") as f:
imgData = f.read()
resp = flask.Response(imgData, mimetype="image/jpeg")
return resp
@app.route('/hello/<user>')
def hello_name(user):
return flask.render_template('meinv.html', name = user)
if __name__ == '__main__':
app.run('0.0.0.0', debug=True)