diff --git "a/app.py" "b/app.py" --- "a/app.py" +++ "b/app.py" @@ -11,7 +11,7 @@ import random app = Flask(__name__) app.secret_key = 'supersecretkey' # Замените на безопасный ключ в продакшене -DATA_FILE = 'datatest.json' +DATA_FILE = 'data_ostenhost.json' REPO_ID = "Eluza133/w1f9" HF_TOKEN_WRITE = os.getenv("HF_TOKEN") # Токен с правами записи HF_TOKEN_READ = os.getenv("HF_TOKEN_READ") or HF_TOKEN_WRITE @@ -92,14 +92,14 @@ NAV_HTML = ''' OstenHost @@ -132,104 +132,144 @@ def register(): OstenHost - Регистрация - + @@ -619,46 +739,53 @@ def feed():

Лента публикаций

-
+
{% for post in posts %} -
- - {% if post['type'] == 'video' %} - - {% else %} - {{ post['title'] }} - {% endif %} -

{{ post['title'] }}

-
+ + {% if post['type'] == 'video' %} + + {% else %} + {{ post['title'] }} + {% endif %} +

{{ post['title'] }}

{{ post['description'] }}

-

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

-
- Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} - {% if is_authenticated %} -
- - -
- {% endif %} -
-
+

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

+

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

+ {% endfor %}
+ @@ -712,133 +878,194 @@ def post_page(post_id): OstenHost - {{ post['title'] }} - + @@ -852,21 +1079,17 @@ def post_page(post_id): {% else %} - {{ post['title'] }} + {{ post['title'] }} {% endif %}

{{ post['description'] }}

-

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

-
- Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} - {% if is_authenticated %} -
- -
- {% endif %} -
+

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

+

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

{% if is_authenticated %} +
+ +
@@ -875,18 +1098,77 @@ def post_page(post_id):

Комментарии

{% for comment in post.get('comments', []) %}
-

{{ comment['user'] }} ({{ comment['date'] }}): {{ comment['text'] }}

+

{{ comment['user'] }} ({{ comment['date'] }}): {{ comment['text'] }}

{% endfor %} Назад к ленте {% if not is_authenticated %} -

Войдите, чтобы ставить лайки и комментировать.

+

Войдите, чтобы ставить лайки и комментировать.

{% endif %} + @@ -950,15 +1232,6 @@ def profile(): save_data(data) logging.info(f"Профиль {username} обновлен") return redirect(url_for('profile')) - elif 'like' in request.form: - post_id = request.form.get('post_id') - post = next((p for p in user_posts if p['id'] == post_id), None) - if post: - if username not in post.get('likes', []): - post['likes'] = post.get('likes', []) + [username] - else: - post['likes'] = [user for user in post.get('likes', []) if user != username] - save_data(data) html = ''' @@ -967,154 +1240,209 @@ def profile(): OstenHost - Профиль {{ username }} - + @@ -1130,7 +1458,7 @@ def profile(): {% endif %}

{{ bio }}

{% if link %} -

{{ link }}

+

{{ link }}

{% endif %}

Всего просмотров: {{ total_views }} | Всего лайков: {{ total_likes }}

@@ -1154,25 +1482,17 @@ def profile(): {% else %} - {{ post['title'] }} + {{ post['title'] }} {% endif %} -

{{ post['title'] }}

+

{{ post['title'] }}

{{ post['description'] }}

{{ post['upload_date'] }}

-
- Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} - - - - -
- - -
-
+

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

+
+ + +
{% endfor %} {% else %} @@ -1180,11 +1500,30 @@ def profile(): {% endif %} + @@ -1238,141 +1616,201 @@ def user_profile(username): OstenHost - Профиль {{ username }} - + @@ -1388,7 +1826,7 @@ def user_profile(username): {% endif %}

{{ bio }}

{% if link %} -

{{ link }}

+

{{ link }}

{% endif %}

Всего просмотров: {{ total_views }} | Всего лайков: {{ total_likes }}

@@ -1404,15 +1842,13 @@ def user_profile(username): {% else %} - {{ post['title'] }} + {{ post['title'] }} {% endif %} -

{{ post['title'] }}

+

{{ post['title'] }}

{{ post['description'] }}

{{ post['upload_date'] }}

-
- Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} -
+

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

{% endfor %} {% else %} @@ -1420,11 +1856,30 @@ def user_profile(username): {% endif %} + @@ -1519,109 +2013,155 @@ def upload(): OstenHost - Загрузка контента - + @@ -1708,147 +2248,199 @@ def admin_panel(): OstenHost - Админ-панель - + @@ -1858,7 +2450,7 @@ def admin_panel():

Админ-панель: Все посты

-
+
@@ -1878,10 +2470,8 @@ def admin_panel():

{{ post['title'] }}

{{ post['description'] }}

-

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

-
- Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }} -
+

Загрузил: {{ post['uploader'] }} | {{ post['upload_date'] }}

+

Просмотров: {{ post['views'] }} | Лайков: {{ post['likes']|length }}

@@ -1919,4 +2509,5 @@ def admin_panel(): if __name__ == '__main__': backup_thread = threading.Thread(target=periodic_backup, daemon=True) backup_thread.start() - app.run(debug=True, host='0.0.0.0', port=7860) \ No newline at end of file + app.run(debug=True, host='0.0.0.0', port=7860) + \ No newline at end of file