create route function +create.html

master
grgr 2 years ago
parent 4da31e0699
commit 2b632ff905

Binary file not shown.

@ -68,20 +68,14 @@ def home():
return render_template('home.html', categories=categories) return render_template('home.html', categories=categories)
# @app.route("/add", methods=['GET', 'POST']) @app.route("/add/", methods=['GET', 'POST'])
# def create(): def create():
# # the goal here is to choose from a list of parameters what you want to add conn = get_db_connection()
# # 1- ogni blocco del form dovrebbe essere una tabella a parte
# if request.method == 'POST': categories = conn.execute('SELECT title FROM categories;').fetchall()
# title = request.form.get('title') conn.close()
# author = request.form.get('author')
# description = request.form.get('description') return render_template('create.html', categories=categories)
# add_book(author, title, description)
# # if author:
# # return url_for('add_new_author')
# return redirect(url_for('home'))
# return render_template('add_new.html')
# app.run(port=3148) # app.run(port=3148)

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>library</title>
</head>
<body>
<!-- <form method="POST" enctype="multipart/form-data">
<input type="text" name="author" placeholder="Author"/>
<input type="text" name="title" placeholder="Title"/>
<textarea name="description" cols="30" rows="10" placeholder="description"></textarea>
<input type="submit" value="Add" />
</form> -->
<div id="panel-container"></div>
</body>
</html>

@ -7,7 +7,7 @@
<!-- <script src="{{url_for('static', filename='addnew_panel.js')}}"></script> --> <!-- <script src="{{url_for('static', filename='addnew_panel.js')}}"></script> -->
</head> </head>
<body> <body>
<!--{# <a class="nav-link" href="{{ url_for('create') }}">New</a> #}--> <a class="nav-link" href="{{ url_for('create') }}">New</a>
{% block content %} {% endblock %} {% block content %} {% endblock %}
</body> </body>
</html> </html>

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>library</title>
</head>
<body>
<select class="form-control" name="cat">
{% for cat in categories %}
{% if cat['title'] == request.form['cat'] %}
<option value="{{ request.form['cat'] }}" selected>
{{ request.form['cat'] }}
</option>
{% else %}
<option value="{{ cat['title'] }}">
{{ cat['title'] }}
</option>
{% endif %}
{% endfor %}
</select>
<div id="panel-container"></div>
</body>
</html>
Loading…
Cancel
Save