Eluza133 commited on
Commit
2920f11
·
verified ·
1 Parent(s): 7f4a093

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -159,7 +159,8 @@ def login():
159
  logging.debug(f"Сохранённый хеш для {username}: {stored_hash}")
160
  if stored_hash == hashed_password:
161
  session['username'] = username
162
- logging.info(f"Успешный вход: {username}")
 
163
  return redirect(url_for('video_feed'))
164
  else:
165
  logging.warning(f"Неверный пароль для {username}")
@@ -224,6 +225,7 @@ def video_feed():
224
  videos = data['videos']
225
  is_authenticated = 'username' in session
226
  username = session.get('username', None)
 
227
  html = '''
228
  <!DOCTYPE html>
229
  <html lang="ru">
@@ -235,7 +237,7 @@ def video_feed():
235
  <style>
236
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
237
  .container { max-width: 1200px; margin: 0 auto; padding-left: 220px; transition: padding-left 0.3s; }
238
- .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; }
239
  .sidebar.active { left: 0; }
240
  .video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
241
  .video-item { background: #fff; padding: 15px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-decoration: none; color: #2d3748; }
@@ -243,7 +245,7 @@ def video_feed():
243
  .auth-links, .upload-btn, .logout-btn, .profile-link { display: block; margin: 10px 0; padding: 10px; background: #3b82f6; color: white; text-align: center; text-decoration: none; border-radius: 8px; }
244
  .logout-btn { background: #ef4444; }
245
  .profile-link { background: #10b981; }
246
- .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1000; }
247
  @media (max-width: 768px) {
248
  .container { padding-left: 20px; }
249
  .sidebar { left: -220px; }
@@ -311,14 +313,14 @@ def video_page(title):
311
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
312
  <style>
313
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
314
- .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; }
315
  .sidebar.active { left: 0; }
316
  .container { max-width: 800px; margin: 0 auto; padding-left: 220px; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: padding-left 0.3s; }
317
  video { width: 100%; border-radius: 8px; }
318
  .back-btn, .profile-link, .logout-btn { display: inline-block; margin-top: 10px; padding: 10px; background: #3b82f6; color: white; text-decoration: none; border-radius: 8px; }
319
  .profile-link { background: #10b981; }
320
  .logout-btn { background: #ef4444; }
321
- .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1000; }
322
  @media (max-width: 768px) {
323
  .container { padding-left: 20px; padding: 15px; }
324
  .sidebar { left: -220px; }
@@ -393,7 +395,7 @@ def profile():
393
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
394
  <style>
395
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
396
- .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; }
397
  .sidebar.active { left: 0; }
398
  .container { max-width: 800px; margin: 0 auto; padding-left: 220px; transition: padding-left 0.3s; }
399
  .video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
@@ -403,7 +405,7 @@ def profile():
403
  .delete-btn { background: #ef4444; border: none; cursor: pointer; }
404
  .profile-link { background: #10b981; }
405
  .logout-btn { background: #ef4444; }
406
- .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1000; }
407
  @media (max-width: 768px) {
408
  .container { padding-left: 20px; }
409
  .sidebar { left: -220px; }
@@ -519,7 +521,7 @@ def upload_video():
519
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
520
  <style>
521
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
522
- .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; }
523
  .sidebar.active { left: 0; }
524
  .container { max-width: 600px; margin: 0 auto; padding-left: 220px; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: padding-left 0.3s; }
525
  input, textarea { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #e2e8f0; border-radius: 8px; box-sizing: border-box; }
@@ -529,7 +531,7 @@ def upload_video():
529
  .profile-link, .logout-btn { display: block; margin: 10px 0; padding: 10px; background: #3b82f6; color: white; text-decoration: none; border-radius: 8px; }
530
  .profile-link { background: #10b981; }
531
  .logout-btn { background: #ef4444; }
532
- .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1000; }
533
  @media (max-width: 768px) {
534
  .container { padding-left: 20px; padding: 15px; }
535
  .sidebar { left: -220px; }
 
159
  logging.debug(f"Сохранённый хеш для {username}: {stored_hash}")
160
  if stored_hash == hashed_password:
161
  session['username'] = username
162
+ session.permanent = True # Сессия сохраняется дольше
163
+ logging.info(f"Успешный вход: {username}, сессия: {session['username']}")
164
  return redirect(url_for('video_feed'))
165
  else:
166
  logging.warning(f"Неверный пароль для {username}")
 
225
  videos = data['videos']
226
  is_authenticated = 'username' in session
227
  username = session.get('username', None)
228
+ logging.debug(f"Сессия на главной: is_authenticated={is_authenticated}, username={username}")
229
  html = '''
230
  <!DOCTYPE html>
231
  <html lang="ru">
 
237
  <style>
238
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
239
  .container { max-width: 1200px; margin: 0 auto; padding-left: 220px; transition: padding-left 0.3s; }
240
+ .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; z-index: 1000; }
241
  .sidebar.active { left: 0; }
242
  .video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
243
  .video-item { background: #fff; padding: 15px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-decoration: none; color: #2d3748; }
 
245
  .auth-links, .upload-btn, .logout-btn, .profile-link { display: block; margin: 10px 0; padding: 10px; background: #3b82f6; color: white; text-align: center; text-decoration: none; border-radius: 8px; }
246
  .logout-btn { background: #ef4444; }
247
  .profile-link { background: #10b981; }
248
+ .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1001; }
249
  @media (max-width: 768px) {
250
  .container { padding-left: 20px; }
251
  .sidebar { left: -220px; }
 
313
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
314
  <style>
315
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
316
+ .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; z-index: 1000; }
317
  .sidebar.active { left: 0; }
318
  .container { max-width: 800px; margin: 0 auto; padding-left: 220px; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: padding-left 0.3s; }
319
  video { width: 100%; border-radius: 8px; }
320
  .back-btn, .profile-link, .logout-btn { display: inline-block; margin-top: 10px; padding: 10px; background: #3b82f6; color: white; text-decoration: none; border-radius: 8px; }
321
  .profile-link { background: #10b981; }
322
  .logout-btn { background: #ef4444; }
323
+ .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1001; }
324
  @media (max-width: 768px) {
325
  .container { padding-left: 20px; padding: 15px; }
326
  .sidebar { left: -220px; }
 
395
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
396
  <style>
397
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
398
+ .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; z-index: 1000; }
399
  .sidebar.active { left: 0; }
400
  .container { max-width: 800px; margin: 0 auto; padding-left: 220px; transition: padding-left 0.3s; }
401
  .video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
 
405
  .delete-btn { background: #ef4444; border: none; cursor: pointer; }
406
  .profile-link { background: #10b981; }
407
  .logout-btn { background: #ef4444; }
408
+ .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1001; }
409
  @media (max-width: 768px) {
410
  .container { padding-left: 20px; }
411
  .sidebar { left: -220px; }
 
521
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
522
  <style>
523
  body { font-family: 'Poppins', sans-serif; background: #f0f2f5; padding: 20px; margin: 0; }
524
+ .sidebar { position: fixed; left: -220px; top: 0; width: 200px; height: 100%; background: #fff; padding: 20px; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s; z-index: 1000; }
525
  .sidebar.active { left: 0; }
526
  .container { max-width: 600px; margin: 0 auto; padding-left: 220px; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: padding-left 0.3s; }
527
  input, textarea { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #e2e8f0; border-radius: 8px; box-sizing: border-box; }
 
531
  .profile-link, .logout-btn { display: block; margin: 10px 0; padding: 10px; background: #3b82f6; color: white; text-decoration: none; border-radius: 8px; }
532
  .profile-link { background: #10b981; }
533
  .logout-btn { background: #ef4444; }
534
+ .menu-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; position: fixed; top: 20px; left: 20px; z-index: 1001; }
535
  @media (max-width: 768px) {
536
  .container { padding-left: 20px; padding: 15px; }
537
  .sidebar { left: -220px; }