This commit is contained in:
parent
1173482a57
commit
4024f8f032
19
app.py
19
app.py
@ -66,17 +66,24 @@ def page_posts_from_db():
|
||||
return render_template("interactive-posts.html", postos=postos)
|
||||
|
||||
|
||||
@app.route('/post_my_post', methods=['POST'])
|
||||
def post_a_post():
|
||||
@app.route('/post_my_post/<post_key>', methods=['POST'])
|
||||
def post_a_post(post_key):
|
||||
|
||||
|
||||
postos = db.collection('posts')
|
||||
novenkiy = {
|
||||
'texto': 'next post is this',
|
||||
}
|
||||
|
||||
|
||||
#### TODO проверить как-то по-умному что мы таки его добавили
|
||||
metadata = postos.insert(novenkiy, overwrite_mode='update')
|
||||
metadata = postos.insert({
|
||||
'texto': 'next post is this',
|
||||
}, overwrite_mode='update')
|
||||
|
||||
db.collection('posts').insert({
|
||||
'_key': post_key,
|
||||
'_from': f'posts/post_key',
|
||||
'_to': f'posts/{metadata["_key"]}'
|
||||
}, overwrite_mode='update')
|
||||
|
||||
|
||||
postos = db.collection('posts')
|
||||
return render_template("i-posts.html", postos=postos)
|
||||
|
@ -25,7 +25,7 @@
|
||||
</div>
|
||||
<div class="col s12">
|
||||
<div class="card-action right">
|
||||
<a href="#" hx-post="/post_my_post" hx-target="#neu-posts" >Answer me!</a>
|
||||
<a href="#" hx-post="/post_my_post/{{ posto._key }}" hx-target="#neu-posts" >Answer me!</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user