Ejemplo n.º 1
0
def topology():
    if 'file' not in request.files:
        flash('Потрібно вибрати файл', category='error')
        return redirect(url_for('index'))
    file = request.files['file']
    filename = file.filename
    if filename == '':
        flash('Файл не вибрано', category='error')
        return redirect(url_for('index'))
    ext = os.path.splitext(filename)[1][1:]
    if not allowed_file(filename):
        flash('Формат {} не підтримується'.format(ext), category='error')
        return redirect(url_for('index'))
    topology = Topology(file=file.stream, type=ext)
    return render_template('topology.html', t=topology.make_report())