Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ import base64
|
|
| 13 |
app = Flask(__name__)
|
| 14 |
app.secret_key = 'supersecretkey' # Замените на безопасный ключ в продакшене
|
| 15 |
DATA_FILE = 'data_adusis.json'
|
| 16 |
-
REPO_ID = "Eluza133/
|
| 17 |
HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
|
| 18 |
HF_TOKEN_READ = os.getenv("HF_TOKEN_READ") or HF_TOKEN_WRITE
|
| 19 |
|
|
@@ -359,7 +359,6 @@ NAV_HTML = '''
|
|
| 359 |
</aside>
|
| 360 |
'''
|
| 361 |
|
| 362 |
-
# Исправленный базовый шаблон - убираем дублирование title
|
| 363 |
BASE_HTML = '''
|
| 364 |
<!DOCTYPE html>
|
| 365 |
<html lang="en">
|
|
@@ -434,8 +433,7 @@ def register():
|
|
| 434 |
user_count = len(data['users'])
|
| 435 |
is_online = is_user_online(data, username) if is_authenticated else False
|
| 436 |
|
| 437 |
-
html = BASE_HTML + '''
|
| 438 |
-
{% block title %}Register - Content Hub{% endblock %}
|
| 439 |
{% block content %}
|
| 440 |
<style>
|
| 441 |
.auth-container {
|
|
@@ -513,8 +511,7 @@ def login():
|
|
| 513 |
user_count = len(data['users'])
|
| 514 |
is_online = is_user_online(data, username) if is_authenticated else False
|
| 515 |
|
| 516 |
-
html = BASE_HTML + '''
|
| 517 |
-
{% block title %}Login - Content Hub{% endblock %}
|
| 518 |
{% block content %}
|
| 519 |
<style>
|
| 520 |
.auth-container {
|
|
@@ -603,8 +600,7 @@ def feed():
|
|
| 603 |
if search_query:
|
| 604 |
posts = [post for post in posts if search_query in post['title'].lower() or search_query in post['description'].lower()]
|
| 605 |
|
| 606 |
-
html = BASE_HTML + '''
|
| 607 |
-
{% block title %}Adusis - QoS, BBC, BNWO HUB{% endblock %}
|
| 608 |
{% block content %}
|
| 609 |
<style>
|
| 610 |
h1 {
|
|
@@ -746,8 +742,7 @@ def post_page(post_id):
|
|
| 746 |
post['comments'] = post.get('comments', []) + [{'user': username, 'text': comment_text, 'date': datetime.now().strftime('%Y-%m-%d %H:%M:%S')}]
|
| 747 |
save_data(data)
|
| 748 |
|
| 749 |
-
html = BASE_HTML + '''
|
| 750 |
-
{% block title %}{{ post['title'] }} - Content Hub{% endblock %}
|
| 751 |
{% block content %}
|
| 752 |
<style>
|
| 753 |
.post-container {
|
|
@@ -874,8 +869,7 @@ def profile():
|
|
| 874 |
save_data(data)
|
| 875 |
return redirect(url_for('profile'))
|
| 876 |
|
| 877 |
-
html = BASE_HTML + '''
|
| 878 |
-
{% block title %}Profile - {{ username }} - Content Hub{% endblock %}
|
| 879 |
{% block content %}
|
| 880 |
<style>
|
| 881 |
.profile-header {
|
|
@@ -1008,8 +1002,7 @@ def user_profile(username):
|
|
| 1008 |
profile_is_online = is_user_online(data, username)
|
| 1009 |
last_seen = user_data.get('last_seen', 'Never')
|
| 1010 |
|
| 1011 |
-
html = BASE_HTML + '''
|
| 1012 |
-
{% block title %}Profile - {{ username }} - Content Hub{% endblock %}
|
| 1013 |
{% block content %}
|
| 1014 |
<style>
|
| 1015 |
.profile-header {
|
|
@@ -1163,8 +1156,7 @@ def upload():
|
|
| 1163 |
os.remove(temp_path)
|
| 1164 |
return redirect(url_for('profile'))
|
| 1165 |
|
| 1166 |
-
html = BASE_HTML + '''
|
| 1167 |
-
{% block title %}Upload Content - Content Hub{% endblock %}
|
| 1168 |
{% block content %}
|
| 1169 |
<style>
|
| 1170 |
.upload-container {
|
|
@@ -1280,8 +1272,7 @@ def chat():
|
|
| 1280 |
save_data(data)
|
| 1281 |
return redirect(url_for('chat'))
|
| 1282 |
|
| 1283 |
-
html = BASE_HTML + '''
|
| 1284 |
-
{% block title %}General Chat - Content Hub{% endblock %}
|
| 1285 |
{% block content %}
|
| 1286 |
<style>
|
| 1287 |
.chat-container {
|
|
@@ -1386,8 +1377,7 @@ def users():
|
|
| 1386 |
if search_query:
|
| 1387 |
user_list = [u for u in user_list if search_query in u[0].lower()]
|
| 1388 |
|
| 1389 |
-
html = BASE_HTML + '''
|
| 1390 |
-
{% block title %}Users - Content Hub{% endblock %}
|
| 1391 |
{% block content %}
|
| 1392 |
<style>
|
| 1393 |
.users-container {
|
|
@@ -1484,8 +1474,7 @@ def messages():
|
|
| 1484 |
'online': is_user_online(data, other_user)
|
| 1485 |
}
|
| 1486 |
|
| 1487 |
-
html = BASE_HTML + '''
|
| 1488 |
-
{% block title %}Messages - Content Hub{% endblock %}
|
| 1489 |
{% block content %}
|
| 1490 |
<style>
|
| 1491 |
.messages-container {
|
|
@@ -1497,7 +1486,7 @@ def messages():
|
|
| 1497 |
animation: slideIn 0.5s ease;
|
| 1498 |
}
|
| 1499 |
body.dark .messages-container { background: var(--card-bg-dark); }
|
| 1500 |
-
h1 { font-size: 2em; background: linear-gradient(
|
| 1501 |
.dialog-list { display: flex; flex-direction: column; gap: 10px; }
|
| 1502 |
.dialog-item { background: var(--card-bg-light); padding: 15px; border-radius: 10px; box-shadow: var(--shadow); transition: var(--transition); display: flex; align-items: center; gap: 10px; }
|
| 1503 |
body.dark .dialog-item { background: var(--card-bg-dark); }
|
|
@@ -1523,7 +1512,7 @@ def messages():
|
|
| 1523 |
{% endif %}
|
| 1524 |
<div class="dialog-info">
|
| 1525 |
<a href="{{ url_for('private_chat', recipient=other_user) }}">{{ other_user }}</a>
|
| 1526 |
-
<span class="status-dot {{ 'online' if info.online else '
|
| 1527 |
{% if info.last_message %}
|
| 1528 |
<p style="font-size: 0.9em; color: rgba(0, 0, 0, 0.6);">{{ info.last_message['time'] }}:
|
| 1529 |
{% if 'text' in info.last_message %}{{ info.last_message['text']|truncate(25) }}{% elif 'file' in info.last_message %}File{% elif 'post_id' in info.last_message %}Post{% endif %}</p>
|
|
@@ -1618,8 +1607,7 @@ def private_chat(recipient):
|
|
| 1618 |
recipient_online = is_user_online(data, recipient)
|
| 1619 |
avatar = data['users'][username].get('avatar') if is_authenticated else None
|
| 1620 |
|
| 1621 |
-
html = BASE_HTML + '''
|
| 1622 |
-
{% block title %}Chat with {{ recipient }} - Content Hub{% endblock %}
|
| 1623 |
{% block content %}
|
| 1624 |
<style>
|
| 1625 |
.chat-container {
|
|
@@ -1758,8 +1746,7 @@ def admin_panel():
|
|
| 1758 |
save_data(data)
|
| 1759 |
return redirect(url_for('admin_panel'))
|
| 1760 |
|
| 1761 |
-
html = BASE_HTML + '''
|
| 1762 |
-
{% block title %}Admin Panel - Content Hub{% endblock %}
|
| 1763 |
{% block content %}
|
| 1764 |
<style>
|
| 1765 |
.admin-container {
|
|
|
|
| 13 |
app = Flask(__name__)
|
| 14 |
app.secret_key = 'supersecretkey' # Замените на безопасный ключ в продакшене
|
| 15 |
DATA_FILE = 'data_adusis.json'
|
| 16 |
+
REPO_ID = "Eluza133/w1f9"
|
| 17 |
HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
|
| 18 |
HF_TOKEN_READ = os.getenv("HF_TOKEN_READ") or HF_TOKEN_WRITE
|
| 19 |
|
|
|
|
| 359 |
</aside>
|
| 360 |
'''
|
| 361 |
|
|
|
|
| 362 |
BASE_HTML = '''
|
| 363 |
<!DOCTYPE html>
|
| 364 |
<html lang="en">
|
|
|
|
| 433 |
user_count = len(data['users'])
|
| 434 |
is_online = is_user_online(data, username) if is_authenticated else False
|
| 435 |
|
| 436 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'Register - Content Hub') + '''
|
|
|
|
| 437 |
{% block content %}
|
| 438 |
<style>
|
| 439 |
.auth-container {
|
|
|
|
| 511 |
user_count = len(data['users'])
|
| 512 |
is_online = is_user_online(data, username) if is_authenticated else False
|
| 513 |
|
| 514 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'Login - Content Hub') + '''
|
|
|
|
| 515 |
{% block content %}
|
| 516 |
<style>
|
| 517 |
.auth-container {
|
|
|
|
| 600 |
if search_query:
|
| 601 |
posts = [post for post in posts if search_query in post['title'].lower() or search_query in post['description'].lower()]
|
| 602 |
|
| 603 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'Adusis - QoS, BBC, BNWO HUB') + '''
|
|
|
|
| 604 |
{% block content %}
|
| 605 |
<style>
|
| 606 |
h1 {
|
|
|
|
| 742 |
post['comments'] = post.get('comments', []) + [{'user': username, 'text': comment_text, 'date': datetime.now().strftime('%Y-%m-%d %H:%M:%S')}]
|
| 743 |
save_data(data)
|
| 744 |
|
| 745 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', f"{post['title']} - Content Hub") + '''
|
|
|
|
| 746 |
{% block content %}
|
| 747 |
<style>
|
| 748 |
.post-container {
|
|
|
|
| 869 |
save_data(data)
|
| 870 |
return redirect(url_for('profile'))
|
| 871 |
|
| 872 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', f"Profile - {username} - Content Hub") + '''
|
|
|
|
| 873 |
{% block content %}
|
| 874 |
<style>
|
| 875 |
.profile-header {
|
|
|
|
| 1002 |
profile_is_online = is_user_online(data, username)
|
| 1003 |
last_seen = user_data.get('last_seen', 'Never')
|
| 1004 |
|
| 1005 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', f"Profile - {username} - Content Hub") + '''
|
|
|
|
| 1006 |
{% block content %}
|
| 1007 |
<style>
|
| 1008 |
.profile-header {
|
|
|
|
| 1156 |
os.remove(temp_path)
|
| 1157 |
return redirect(url_for('profile'))
|
| 1158 |
|
| 1159 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'Upload Content - Content Hub') + '''
|
|
|
|
| 1160 |
{% block content %}
|
| 1161 |
<style>
|
| 1162 |
.upload-container {
|
|
|
|
| 1272 |
save_data(data)
|
| 1273 |
return redirect(url_for('chat'))
|
| 1274 |
|
| 1275 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'General Chat - Content Hub') + '''
|
|
|
|
| 1276 |
{% block content %}
|
| 1277 |
<style>
|
| 1278 |
.chat-container {
|
|
|
|
| 1377 |
if search_query:
|
| 1378 |
user_list = [u for u in user_list if search_query in u[0].lower()]
|
| 1379 |
|
| 1380 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'Users - Content Hub') + '''
|
|
|
|
| 1381 |
{% block content %}
|
| 1382 |
<style>
|
| 1383 |
.users-container {
|
|
|
|
| 1474 |
'online': is_user_online(data, other_user)
|
| 1475 |
}
|
| 1476 |
|
| 1477 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'Messages - Content Hub') + '''
|
|
|
|
| 1478 |
{% block content %}
|
| 1479 |
<style>
|
| 1480 |
.messages-container {
|
|
|
|
| 1486 |
animation: slideIn 0.5s ease;
|
| 1487 |
}
|
| 1488 |
body.dark .messages-container { background: var(--card-bg-dark); }
|
| 1489 |
+
h1 { font-size: 2em; background: linear-gradient(135degvar(--primary), var(--accent)); -webkit-background-clip: text; color: transparent; margin-bottom: 20px; }
|
| 1490 |
.dialog-list { display: flex; flex-direction: column; gap: 10px; }
|
| 1491 |
.dialog-item { background: var(--card-bg-light); padding: 15px; border-radius: 10px; box-shadow: var(--shadow); transition: var(--transition); display: flex; align-items: center; gap: 10px; }
|
| 1492 |
body.dark .dialog-item { background: var(--card-bg-dark); }
|
|
|
|
| 1512 |
{% endif %}
|
| 1513 |
<div class="dialog-info">
|
| 1514 |
<a href="{{ url_for('private_chat', recipient=other_user) }}">{{ other_user }}</a>
|
| 1515 |
+
<span class="status-dot {{ 'online' if info.online else 'OFFLINE' }}"></span>
|
| 1516 |
{% if info.last_message %}
|
| 1517 |
<p style="font-size: 0.9em; color: rgba(0, 0, 0, 0.6);">{{ info.last_message['time'] }}:
|
| 1518 |
{% if 'text' in info.last_message %}{{ info.last_message['text']|truncate(25) }}{% elif 'file' in info.last_message %}File{% elif 'post_id' in info.last_message %}Post{% endif %}</p>
|
|
|
|
| 1607 |
recipient_online = is_user_online(data, recipient)
|
| 1608 |
avatar = data['users'][username].get('avatar') if is_authenticated else None
|
| 1609 |
|
| 1610 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', f"Chat with {recipient} - Content Hub") + '''
|
|
|
|
| 1611 |
{% block content %}
|
| 1612 |
<style>
|
| 1613 |
.chat-container {
|
|
|
|
| 1746 |
save_data(data)
|
| 1747 |
return redirect(url_for('admin_panel'))
|
| 1748 |
|
| 1749 |
+
html = BASE_HTML.replace('{% block title %}{% endblock %}', 'Admin Panel - Content Hub') + '''
|
|
|
|
| 1750 |
{% block content %}
|
| 1751 |
<style>
|
| 1752 |
.admin-container {
|