增加新功能
This commit is contained in:
parent
68efaea7fb
commit
391aadf5eb
20
app.py
20
app.py
@ -4,6 +4,7 @@ import os
|
||||
import subprocess
|
||||
import json
|
||||
import uuid
|
||||
from math import ceil
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = str(uuid.uuid4())
|
||||
@ -107,12 +108,27 @@ def index():
|
||||
proxy_address=config['proxy_address'],
|
||||
proxy_port=config['proxy_port'])
|
||||
|
||||
|
||||
# 在 clients 路由中增加分页逻辑
|
||||
@app.route('/clients')
|
||||
@basic_auth_required
|
||||
def clients():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
per_page = 5
|
||||
|
||||
users = read_squid_file()
|
||||
return render_template('clients.html', users=users)
|
||||
total_pages = ceil(len(users) / per_page)
|
||||
|
||||
start = (page - 1) * per_page
|
||||
end = start + per_page
|
||||
paginated_users = users[start:end]
|
||||
|
||||
return render_template('clients.html',
|
||||
users=paginated_users,
|
||||
page=page,
|
||||
total_pages=total_pages)
|
||||
|
||||
|
||||
# 其他代码保持不变...
|
||||
|
||||
|
||||
@app.route('/settings')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user