Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def user_signup():
form = SignupForm()
if form.validate_on_submit():
active_user = app.config.get('PERMISSIONS', DEFAULT_PERMISSIONS) != PERMISSIONS_PRIVATE
app.users.add_user(form.name.data, form.password.data,
form.full_name.data, form.email.data, active_user,
authentication_method=get_default_authentication_method())
flash('You were registered successfully. Please login now.', 'success')
if not active_user:
flash('Your user is inactive by default, please contact the wiki admin', 'error')
return redirect(request.args.get('next') or url_for('index'))
return render_template('signup.html', form=form)
def plot():
cname = request.args.get("collection")
if not cname:
return make_response(render_template('plot.html', collections=CNAMES))
else:
cname = cname.split(":")[0]
plot_type = request.args.get("plot_type") or "scatter"
search_string = request.args.get("search_string")
xaxis = request.args.get("xaxis")
yaxis = request.args.get("yaxis")
return make_response(render_template(
'plot.html', collection=cname,
search_string=search_string, plot_type=plot_type,
xaxis=xaxis, yaxis=yaxis,
active_collection=cname,
collections=CNAMES, app_title=APP_TITLE,
plot=True)
)
return "OK"
elif command in ["get_advanced_settings", "set_advanced_settings"]:
if session.get('write_access', True):
if command == "get_advanced_settings":
data = ReadAdvancedSettingsFromFile()
return json.dumps(data, sort_keys = False)
elif command == "set_advanced_settings":
SaveAdvancedSettings(request.args.get('set_advanced_settings', default = None, type=str))
else:
return "OK"
return "OK"
elif command in ["setsettings"]:
if session.get('write_access', True):
SaveSettings(request.args.get('setsettings', 0, type=str))
return "OK"
elif command in ["getreglabels"]:
return jsonify(CachedRegisterDescriptions)
elif command in ["restart"]:
if session.get('write_access', True):
Restart()
elif command in ["stop"]:
if session.get('write_access', True):
Close()
sys.exit(0)
elif command in ["shutdown"]:
if session.get('write_access', True):
Shutdown()
sys.exit(0)
@wraps(fn)
def decorated(*args, **kwargs):
#return fn(*args, **kwargs)
print request.get_json()
rToken = request.get_json().get("token")
argsToken = request.args.get('token')
#return _get_unauthorized_response()
for token in AuthToken.objects:
if rToken == token.token or argsToken == token.token:
print token.user_id
return fn(*args, **kwargs)
return _get_unauthorized_response()
return decorated
def hello_get():
sentence = request.args.get('sentence')
if not sentence:
return "No sentence", 400
sentence = "hello"
return jsonify({
'original': sentence,
})
def get(self):
content = request.args.get('content',None)
file_name = request.args.get('file_name',None)
continue_edit = int(request.args.get('continue_edit',0))
success = save_file(file_name,content)
if success:
flash(self._SUCCESS_MESSAGE.format(file_name),'success')
else:
flash(self._ERROR_MESSAGE.format(file_name),'danger')
return jsonify(dict(success=success,continue_edit=bool(continue_edit)))
def graph_traversal(graph):
"""Search traversal."""
try:
search_dict = {
'graph_name': graph,
'start_vertex': request.args.get('start_vertex'),
'direction': request.args.get('direction', 'outbound'),
'item_order': request.args.get('item_order', 'forward'),
'strategy': request.args.get('strategy', None),
'order': request.args.get('order', None),
'edge_uniqueness': request.args.get('edge_uniqueness', None),
'vertex_uniqueness': request.args.get('vertex_uniqueness', None),
'max_iter': request.args.get('max_iter', None),
'min_depth': request.args.get('min_depth', None),
'max_depth': request.args.get('max_depth', None),
'init_func': request.args.get('init_func', None),
'sort_func': request.args.get('sort_func', None),
'filter_func': request.args.get('filter_func', None),
'visitor_func': request.args.get('visitor_func', None),
'expander_func': request.args.get('expander_func', None)
}
res = facade.search_traversal(**search_dict)
return res, 200
except gmap_exc.GraphNotExist as err:
return err.message, 404
except Exception as err:
return str(err), 500
def get_request_page(self):
page = flask.request.args.get(self.page_arg)
try:
return self.parse_page(page)
except ApiError as e:
raise e.update({'source': {'query': self.page_arg}})
return ctx
# put parameters into template
metric = flask.request.args.get('metric')
if metric not in METRIC_LABELS:
metric = None
ctx['metric'] = metric or DEFAULT_METRIC
period = flask.request.args.get('period')
if period not in PERIOD_LABELS:
period = None
ctx['period'] = period or DEFAULT_PERIOD
ctx['metric_label'] = METRIC_LABELS[ctx['metric']]
ctx['period_label'] = PERIOD_LABELS[ctx['period']]
project_type = flask.request.args.get('project_type')
if project_type not in PROJECT_TYPES:
project_type = None
ctx['project_type'] = project_type or DEFAULT_PROJECT_TYPE
ctx['last_update'] = app.config['LAST_UPDATE']
return flask.render_template(template_name, **ctx)
return decorated_function
def rm_node(command):
node_id = request.args.get("node_id")
force_flag = request.args.get("force") == "true"
if not node_id:
return("the node_id argument is necessary")
if not force_flag:
try:
command._do_rm_node_not_catched(node_id)
return("node deleted", 200)
except ValueError as e:
return("node was not deleted, set the force argument to true\
to delete all nodes of this type from subgraphs", 412)
else:
try:
command._do_rm_node_force_not_catched(node_id)
return("node deleted", 200)
except ValueError as e:
return("error " + str(e), 412)