@app.route('/result')
def result():
username = request.args.get('username')
ok_message=''
reject_message=''
uppercase_err_message=''
num_err_message=''
has_upper = any([i.isupper() for i in username])
has_digit = any([i.isdigit() for i in username])
if not has_upper:
uppercase_err_message = 'Need an UPPERCASE'
elif not has_digit:
num_err_message = 'need a NUM'
if has_upper and has_digit:
ok_message = 'ALL GOOD!'
else:
reject_message = 'NOT GOOD...'
return render_template(
'result.html',
username=username,
ok_message=ok_message,
reject_message=reject_message,
uppercase_err_message=uppercase_err_message,
num_err_message=num_err_message
)
data.update({'bye': "godbye"})
a = [1, 2, 23, 4, 5, 6, 7, 40, 9, 10, 100, 12, 13, 14, 15, 700, 17, 18, 19, 20]
for index, group in reversed(list([(i, a[i:i+5]) for i in range(0, len(a), 5)])):
s = sum(group)
a.insert(index + 5, s)
print(f'{index} {group} => {s}')
# 15 [700, 17, 18, 19, 20] => 774
# 10 [100, 12, 13, 14, 15] => 154
# 5 [6, 7, 40, 9, 10] => 72
# 0 [1, 2, 23, 4, 5] => 35
# a
# [1, 2, 23, 4, 5, 35, 6, 7, 40, 9, 10, 72, 100, 12, 13, 14, 15, 154, 700, 17, 18, 19, 20, 774]
if request.method == 'POST':
username = request.form.get('username') # запрос к данным формы
password = request.form.get('password')
if username == 'root' and password == 'pass':
message = "Correct username and password"
else:
message = "Wrong username or password"
import math
with open('file.txt', 'r+', encoding='utf-8') as file:
data = file.read()
for line in data.splitlines():
if line.startswith('ld r'):
splited = line.split()
midpoint = math.ceil(len(splited) / 2)
splited.insert(midpoint, 'at right')
new_line = ' '.join(splited)
data = data.replace(line, new_line)
file.seek(0)
file.write(data)
file.truncate()
И боты у меня крутые, даже очень. Так что не гони на меня что я не могу делать ботов. Я основы знаю очень даже хорошо, и не только..
id
а к текстовому поля указатель на форму:<label>
<textarea name="recipe" rows="15" cols="55" form="some-form"></textarea>
</label>
<form id="some-form" action="/save" method="POST">
<input type="submit" value="Сохранить">
</form>
import logging
@app.route('/create-poem/', methods=['POST', 'GET'])
def create():
if request.method == 'POST':
...
try:
...
except Exception:
logging.exception('')
return ''
else:
...
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: ivan
db.create_all()
app.run(debug=True)
chunked = list(
(list_with_values[i:i+3] for i in range(0, len(list_with_values), 3)))
sql = "INSERT INTO games(game_id, name, date) VALUES (%s, %s, %s)"
cursor.executemany(sql, chunked)
connection.commit()