def index(): form = IPForm() if form.validate_on_submit(): UDP_IP = form.address.data UDP_PORT = form.port.data print(UDP_IP, UDP_PORT) sock.bind((UDP_IP, UDP_PORT)) return redirect(url_for('dashboard')) return render_template('index.html', form=form)
def assignip(request): username = request.session.get('username','') if username: if request.method == "POST": ip = IPForm(request.POST) if ip.is_valid(): iptemp = request.POST.get('assignip') str = 'ifconfig eth1.100 '+iptemp.encode("utf-8")+' netmask 255.255.255.0 up' shellshow('vconfig add eth1 100') shellshow(str) else: ip = IPForm() return render_to_response('assignip.html',{'ip':ip})
def index(): lgform = LoginForm() if lgform.validate_on_submit(): user = User.query.filter_by(username=lgform.username.data).first() if user is not None and user.verify_password(lgform.password.data): login_user(user) return redirect(request.args.get("next") or url_for("index")) ipform = IPForm() if ipform.validate_on_submit(): if not current_user.can(Permission.CRUD_NETWORK): abort(403) notify_monitor_add_ip(ipform.ip.data) return redirect("/index") netform = NetForm() if netform.validate_on_submit(): if not current_user.can(Permission.CRUD_NETWORK): abort(403) notify_monitor_add_network(netform.network.data) return redirect("/index") nodes_dict = MonitorColl.get_network_ip_dict() return render_template("index.html", nodes_dict=nodes_dict, ipform=ipform, netform=netform, lgform=lgform)