<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="{{ url_for('test_form')}}" method='POST'>
<!-- Other Form attributes here -->
<table id="extra-table">
<tr>
<th class="col-md-4">Property</th>
<th class="col-md-4">Value</th>
<th class="col-md-4"></th>
</tr>
{% for extra in form.extras %}
<tr>
<td>{{ extra.key(class_="form-control") }}</td>
<td>{{ extra.value(class_="form-control") }}</td>
<td>
<button type="button" class="btn btn-danger"
onclick="removeExtraRow(this)">
Remove <i class="fas fa-minus"></i>
</button>
</td>
</tr>
{% endfor %}
<button type="button" class="btn btn-info" onclick="addExtraRow()">
Add Row <i class="fas fa-plus"></i>
</button>
</table>
<button type="submit" class="btn btn-success">
Create
</button>
</form>
<script type="text/javascript">
// Function to add a row to the Extra Properties Table
// Function to remove a row from the extra properties table
function removeExtraRow(x) {
let i = x.parentNode.parentNode["rowIndex"];
let table = document.getElementById("extra-table");
table.deleteRow(i);
}
function addExtraRow() {
let table = document.getElementById("extra-table");
let length = table.rows.length + 1;
let row = table.insertRow(-1);
let keyCell = row.insertCell(0);
let valCell = row.insertCell(1);
let cell3 = row.insertCell(2);
keyCell.innerHTML = "<span class=\"bmd-form-group is-filled\"><input class=\"form-control\" id=\"" + length + "-key\" name=\"" + length + "-key\" required=\"\" type=\"text\" value=\"\"></span>";
valCell.innerHTML = "<span class=\"bmd-form-group is-filled\"><input class=\"form-control\" id=\"" + length + "-value\" name=\"" + length + "-value\" required=\"\" type=\"text\" value=\"\"></span>";
cell3.innerHTML = "<button type=\"button\" class=\"btn btn-danger\" onclick=\"removeExtraRow(this)\"> Remove <i class=\"fas fa-minus\"></i> </button>";
}
</script>
</body>
</html>
[('extras-2-key', '11'), ('extras-2-value', 'AAA'), ('extras-3-key', '22'), ('extras-3-value', 'BBB'), ('extras-4-key', '33'), ('extras-4-value', 'CCC')]
with open(sqlname, 'w') as out:
subprocess.call(f'{MYSQLDUMP_FILE} -P {port} -h {dbhost} -u {dbroot} --password={dbrootpw} {database}',
stdout=out)
mydict = {1: {'File': 'Fail-205001.pdf', 'Angle': '0', 'Quantity': 5},
2: {'File': 'Fail-205001.pdf', 'Angle': '0', 'Quantity': 5},
3: {'File': 'Fail-205001.pdf', 'Angle': '0', 'Quantity': 5},
4: {'File': 'Fail-200001.pdf', 'Angle': '0', 'Quantity': 5}}
values = [(d['File'], d['Angle']) for d in mydict]
print(all(f == values[0][0] and a == values[0][1] for f, a in values))
Traceback (most recent call last):
File "E:/Users/Alex/Documents/MyPyProj/compare-dict.py", line 7, in <module>
values = [(d['File'], str(d['Angle'])) for d in mydict]
File "E:/Users/Alex/Documents/MyPyProj/compare-dict.py", line 7, in <listcomp>
values = [(d['File'], str(d['Angle'])) for d in mydict]
TypeError: 'int' object is not subscriptable
mydict = {1: {'File': 'Fail-205001.pdf', 'Angle': '0', 'Quantity': 5},
2: {'File': 'Fail-205001.pdf', 'Angle': '0', 'Quantity': 5},
3: {'File': 'Fail-205001.pdf', 'Angle': '0', 'Quantity': 5},
4: {'File': 'Fail-200001.pdf', 'Angle': '0', 'Quantity': 5}}
set_of_nested_values = {(mydict[key]['File'], mydict[key]['Angle']) for key in mydict}
print(len(set_of_nested_values) == 1)
print(set_of_nested_values)
{('Fail-200001.pdf', '0'), ('Fail-205001.pdf', '0')}
Traceback (most recent call last):
File "E:/Users/Alex/Documents/MyPyProj/parser-links.py", line 57, in <module>
main()
File "E:/Users/Alex/Documents/MyPyProj/parser-links.py", line 51, in main
add_all_links_recursive(HOST + '/')
File "E:/Users/Alex/Documents/MyPyProj/parser-links.py", line 32, in add_all_links_recursive
if all(not link.startswith(prefix) for prefix in FORBIDDEN_PREFIXES):
File "E:/Users/Alex/Documents/MyPyProj/parser-links.py", line 32, in <genexpr>
if all(not link.startswith(prefix) for prefix in FORBIDDEN_PREFIXES):
File "C:\Python38\lib\site-packages\bs4\element.py", line 2080, in __getattr__
raise AttributeError(
AttributeError: ResultSet object has no attribute 'startswith'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
Там только рендер таблицы/формы.
А мне нужно создание
Я уже прикинул, что требуется Статичные полу через Flask-WTF.
А динамическую табличную форму для заполнения, сделать используя js.
Ну и привязать функцию перебора последовательно всех таблиц и строк и добавление результата к тому что посылает submit
Так правильно?
А вывод из БД таблицы будет с использованием бутстрап-тейбл. Там готовый вариант формирования таблицы из html или json