Moved parts of the html separate files
This commit is contained in:
parent
1ba198f130
commit
a8b4c42e32
1
shop.py
1
shop.py
@ -67,7 +67,6 @@ def index():
|
|||||||
|
|
||||||
@app.route('/post', methods=['POST'])
|
@app.route('/post', methods=['POST'])
|
||||||
def handle_data():
|
def handle_data():
|
||||||
pprint(request.form)
|
|
||||||
if "addValue" in request.form:
|
if "addValue" in request.form:
|
||||||
for x in request.form:
|
for x in request.form:
|
||||||
# print(x)
|
# print(x)
|
||||||
|
|||||||
7
templates/addForm.html
Normal file
7
templates/addForm.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<form action="/post" method="post">
|
||||||
|
Name:<br>
|
||||||
|
<input type="text" name="name" value=""><br>
|
||||||
|
Item:<br>
|
||||||
|
<input type="text" name="item" value=""><br><br>
|
||||||
|
<input type="submit" name="addValue"value="Submit">
|
||||||
|
</form>
|
||||||
@ -1,12 +1,4 @@
|
|||||||
<!doctype html>
|
{% include "header.html" %}
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>Shopping List</title>
|
|
||||||
<!-- Latest compiled and minified CSS -->
|
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<link rel="stylesheet" content="text/css" href="/static/css/main.css"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
||||||
|
|
||||||
|
|||||||
9
templates/header.html
Normal file
9
templates/header.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Shopping List</title>
|
||||||
|
<!-- Latest compiled and minified CSS -->
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="stylesheet" content="text/css" href="/static/css/main.css"/>
|
||||||
|
</head>
|
||||||
@ -1,52 +1,12 @@
|
|||||||
<!doctype html>
|
{% include "header.html" %}
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>This is my site</title>
|
|
||||||
<!-- Latest compiled and minified CSS -->
|
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<link rel="stylesheet" content="text/css" href="/static/css/main.css"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
||||||
<aside>
|
<aside>
|
||||||
<form action="/post" method="post">
|
{% include "addForm.html" %}
|
||||||
Name:<br>
|
</aside>
|
||||||
<input type="text" name="name" value=""><br>
|
|
||||||
Item:<br>
|
|
||||||
<input type="text" name="item" value=""><br><br>
|
|
||||||
<input type="submit" name="addValue"value="Submit">
|
|
||||||
</form>
|
|
||||||
</aside>
|
|
||||||
<div class="container" id="memes">
|
<div class="container" id="memes">
|
||||||
<table class="table-striped table">
|
{% include "list.html" %}
|
||||||
<thead class="thead-dark">
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Item</th>
|
|
||||||
<th scope="col">Requester</th>
|
|
||||||
<th scope="col">Gottem?</th>
|
|
||||||
<th scope="col">Remove</th>
|
|
||||||
</tr>
|
|
||||||
{% for x in data["results"] %}
|
|
||||||
<tr id="row-{{x[0]}}">
|
|
||||||
<td>{{x[1]}}</td>
|
|
||||||
<td>{{x[4]}}</td>
|
|
||||||
|
|
||||||
<td> {% if x[3] == 0 %}
|
|
||||||
<form><button type="submit" formaction="/post" formmethod="POST" name="got" value="{{x[0]}}">No</button></form>
|
|
||||||
{% else %}
|
|
||||||
yes
|
|
||||||
{% endif %}</td>
|
|
||||||
<td><form>
|
|
||||||
<button type="submit" formaction="/post" formmethod="POST" name="rem" value="{{x[0]}}">Remove</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- jQuery library -->
|
<!-- jQuery library -->
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||||
|
|
||||||
|
|||||||
25
templates/list.html
Normal file
25
templates/list.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<table class="table-striped table">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Item</th>
|
||||||
|
<th scope="col">Requester</th>
|
||||||
|
<th scope="col">Gottem?</th>
|
||||||
|
<th scope="col">Remove</th>
|
||||||
|
</tr>
|
||||||
|
{% for x in data["results"] %}
|
||||||
|
<tr id="row-{{x[0]}}">
|
||||||
|
<td>{{x[1]}}</td>
|
||||||
|
<td>{{x[4]}}</td>
|
||||||
|
|
||||||
|
<td> {% if x[3] == 0 %}
|
||||||
|
<form><button type="submit" formaction="/post" formmethod="POST" name="got" value="{{x[0]}}">No</button></form>
|
||||||
|
{% else %}
|
||||||
|
yes
|
||||||
|
{% endif %}</td>
|
||||||
|
<td><form>
|
||||||
|
<button type="submit" formaction="/post" formmethod="POST" name="rem" value="{{x[0]}}">Remove</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
@ -1,47 +1,11 @@
|
|||||||
<!doctype html>
|
{% include "header.html" %}
|
||||||
<html lang="en">
|
|
||||||
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Shopping List</title>
|
|
||||||
<!-- Latest compiled and minified CSS -->
|
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<link rel="stylesheet" content="text/css" href="/static/css/main.css"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
<h1 class="container" style="text-align: center">{{ data["title"] }}</h1>
|
||||||
<div class="" style=" text-align: center">
|
<div class="" style=" text-align: center">
|
||||||
<form action="/post" method="post">
|
{% include "addForm.html" %}
|
||||||
Name: <input type="text" name="name" value=""><br>
|
|
||||||
Item: <input type="text" name="item" value=""><br><br>
|
|
||||||
<input type="submit" name="addValue" value="Submit"/>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="container" id="memes">
|
<div class="container" id="memes">
|
||||||
<table class="table-striped table">
|
{% include "list.html" %}
|
||||||
<thead class="thead-dark">
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Item</th>
|
|
||||||
<th scope="col">Requester</th>
|
|
||||||
<th scope="col">Gottem?</th>
|
|
||||||
<th scope="col">Remove</th>
|
|
||||||
</tr>
|
|
||||||
{% for x in data["results"] %}
|
|
||||||
<tr id="row-{{x[0]}}">
|
|
||||||
<td>{{x[1]}}</td>
|
|
||||||
<td>{{x[4]}}</td>
|
|
||||||
|
|
||||||
<td> {% if x[3] == 0 %}
|
|
||||||
<form><button type="submit" formaction="/post" formmethod="POST" name="got" value="{{x[0]}}">No</button></form>
|
|
||||||
{% else %}
|
|
||||||
yes
|
|
||||||
{% endif %}</td>
|
|
||||||
<td><form>
|
|
||||||
<button type="submit" formaction="/post" formmethod="POST" name="rem" value="{{x[0]}}">Remove</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user