Example #1
0
def loadcdn(permission_status):
    if permission_status:
        all_info = pushcdn()
        return render_template('cdn.html',
                               number=all_info.selectnumber(),
                               records_info=all_info.records())
    else:
        flash('Error: 没有权限查看')
    return redirect(url_for('main.index'))
Example #2
0
def index():
    with open(
            os.path.join(current_app.config['SCRIPT_LOCAL_PATH'],
                         'grouping_host_count'), 'r') as files:
        grouping_host_count = pickle.load(files)
    onlien_user_count = len(online_user)
    host_count = db.session.query(Hosts.id).count()
    user_count = db.session.query(User.id).count()
    return render_template('index.html',
                           host_count=host_count,
                           user_count=user_count,
                           onlien_user_count=onlien_user_count,
                           grouping_host_count=grouping_host_count,
                           domain_ranping=pushcdn().get_domain())
Example #3
0
def cdndata(permission_status):
    if permission_status:
        if request.method == 'POST':
            all_info = pushcdn()
            action = request.form.get('action')
            types = request.form.get('types')
            httpurl = request.form.get('httpurl')
            try:
                if action == 'refresh' or types == 'directory':
                    all_info.refredomain(httpurl, types)
                    userlog(current_user.username, request.remote_addr,
                            '预热CDN')
                elif action == 'push':
                    all_info.pushdomain(httpurl)
                    userlog(current_user.username, request.remote_addr,
                            '刷新CDN')
            except Exception as e:
                flash('%s' % e)
            else:
                flash('Success: %s' % httpurl)
        return redirect(url_for('main.loadcdn'))
    else:
        flash('Error: 没有权限操作')
    return redirect(url_for('main.loadcdn'))