Простое решение с ES5 (перезаписать существующее значение):
function merge(current, update) {
Object.keys(update).forEach(function(key) {
// if update[key] exist, and it's not a string or array,
// we go in one level deeper
if (current.hasOwnProperty(key)
&& typeof current[key] === 'object'
&& !(current[key] instanceof Array)) {
merge(current[key], update[key]);
// if update[key] doesn't exist in current, or it's a string
// or array, then assign/overwrite current[key] to update[key]
} else {
current[key] = update[key];
}
});
return current;
}
var x = { a: { a: 1 } }
var y = { a: { b: 1 } }
console.log(merge(x, y));
Из кода JS вызовите (используя метод GET) URL-адрес вашего флеш-маршрута, передав параметры в качестве запросов args:
/list?freesearch=value1&limit_content=value2
Затем в определении вашей функции:
@app.route('/list')
def alist():
freesearch = request.args.get('freesearch')
limitcontent = request.args.get('limit_content')
new = freesearch + limitcontent
return render_template('list.html', title="Projects - "+page_name, new=new)
В качестве альтернативы вы можете использовать переменные пути:
/list/value1/value2
и
@app.route('/list/<freesearch>/<limit_content>')
def alist():
new = free_search + limit_content
return render_template('list.html', title="Projects - "+page_name, new=new)
/list?freesearch=value1,limit_content=value2
в свой javascript? – Bonbin 12 October 2016 в 10:36