复制
收藏
提问
全网

#!/usr/bin/env python # -*- encode: utf-8 -*- from flask import Flask, request, send_from_directory from jinja2 import Environment, FileSystemLoader app = Flask(__name__) env = Environment(loader=FileSystemLoader('./templates')) env.filters['len'] = len def tac(): tacs = [] with open('/Users/wuailun/Downloads/imei_mg/full_info.log', 'r', encoding='utf-8') as f: for line in f: line = line.strip() line = eval(line) tac = line.get('TAC') model = line.get('MODEL').replace(' ', '-') brand = line.get('BRAND').replace(' ', '-') t = line.get('Device type') tacs.append([tac, model, brand, t, f'images/{brand.lower()}-{model.lower()}.jpg']) return tacs @app.route('/') def index(): data = tac() page = int(request.args.get('page', 1)) current_page = page template = env.get_template('t.html') start_index = (page - 1) * 10 end_index = start_index + 10 paginated_data = data[start_index:end_index] return template.render(data=paginated_data, current_page=current_page) @app.route('/images/<path:image_name>') def get_image(image_name): image_directory = '/Users/wuailun/Downloads/imei_mg/pic/' # 图片所在目录的相对路径 return send_from_directory(image_directory, image_name) if __name__ == '__main__': app.run()

甜美工程师
1个月前
全网
文档
学术
百科
知识库
时间不限
自动
您已终止本次搜索,可编辑问题后重新提问。
更专业一些

以上内容由AI搜集生成,仅供参考

在线客服