|
|
@@ -31,9 +31,7 @@ def get_links():
|
|
|
links = Link.query.all()
|
|
|
schema = LinkSchema(many=True)
|
|
|
link_json = schema.dump(links)
|
|
|
- print(link_json)
|
|
|
return links
|
|
|
- #jsonify(link_json)
|
|
|
|
|
|
|
|
|
@app.route('/<string:name>', strict_slashes=False, methods=['GET'])
|
|
|
@@ -60,6 +58,21 @@ def add_link(link_name):
|
|
|
def add_link_form(link_name):
|
|
|
return render_template('add.html', link_name=link_name)
|
|
|
|
|
|
+@app.post('/<string:link_name>/edit', strict_slashes=False)
|
|
|
+def edit_link(link_name):
|
|
|
+ db.create_all()
|
|
|
+ link = Link(name=link_name, target=request.form['target'])
|
|
|
+ db.session.update(link)
|
|
|
+ db.session.commit()
|
|
|
+ return redirect("/", code=302)
|
|
|
+
|
|
|
+
|
|
|
+@app.route('/<string:link_name>/edit', strict_slashes=False)
|
|
|
+def edit_link_form(link_name):
|
|
|
+ link = Link.query.filter_by(name=link_name).first()
|
|
|
+ return render_template('edit.html', link=link)
|
|
|
+
|
|
|
+
|
|
|
@app.post('/<string:link_name>/delete', strict_slashes=False)
|
|
|
def delete_link(link_name):
|
|
|
link = Link.query.filter_by(name=link_name).first()
|
|
|
@@ -71,14 +84,12 @@ def delete_link(link_name):
|
|
|
@app.route('/<string:link_name>/delete', strict_slashes=False)
|
|
|
def delete_link_form(link_name):
|
|
|
link = Link.query.filter_by(name=link_name).first()
|
|
|
- print(link)
|
|
|
return render_template('delete.html', link=link)
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
def hello_world():
|
|
|
links = get_links()
|
|
|
- print(links)
|
|
|
return render_template('list.html', links=links)
|
|
|
|
|
|
#@app.route('/links/<int:id>', methods=['GET'])
|