Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from flask import render_template
|
|
3 |
import sqlite3
|
4 |
import os
|
5 |
import uuid
|
|
|
6 |
|
7 |
app = Flask(__name__, template_folder="./")
|
8 |
|
@@ -68,14 +69,33 @@ def serve_html(filename):
|
|
68 |
filename += '.html'
|
69 |
return send_from_directory(HTML_FOLDER, filename)
|
70 |
|
71 |
-
|
72 |
-
|
73 |
@app.route('/up_page', methods=['GET'])
|
74 |
def up_page():
|
75 |
return render_template('up_page.html')
|
76 |
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
if __name__ == '__main__':
|
81 |
-
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
|
|
3 |
import sqlite3
|
4 |
import os
|
5 |
import uuid
|
6 |
+
import shutil
|
7 |
|
8 |
app = Flask(__name__, template_folder="./")
|
9 |
|
|
|
69 |
filename += '.html'
|
70 |
return send_from_directory(HTML_FOLDER, filename)
|
71 |
|
|
|
|
|
72 |
@app.route('/up_page', methods=['GET'])
|
73 |
def up_page():
|
74 |
return render_template('up_page.html')
|
75 |
|
76 |
+
@app.route('/monitor', methods=['GET'])
|
77 |
+
def monitor():
|
78 |
+
# Получаем информацию о загруженных файлах
|
79 |
+
files = os.listdir(UPLOAD_FOLDER)
|
80 |
+
html_files = os.listdir(HTML_FOLDER)
|
81 |
+
|
82 |
+
# Получаем информацию о дисковом пространстве
|
83 |
+
total, used, free = shutil.disk_usage("/")
|
84 |
+
|
85 |
+
# Преобразуем байты в гигабайты для удобства чтения
|
86 |
+
total_gb = total // (2**30)
|
87 |
+
used_gb = used // (2**30)
|
88 |
+
free_gb = free // (2**30)
|
89 |
|
90 |
+
return jsonify({
|
91 |
+
'uploaded_files': files,
|
92 |
+
'uploaded_html_files': html_files,
|
93 |
+
'disk_space': {
|
94 |
+
'total': f"{total_gb} GB",
|
95 |
+
'used': f"{used_gb} GB",
|
96 |
+
'free': f"{free_gb} GB"
|
97 |
+
}
|
98 |
+
})
|
99 |
|
100 |
if __name__ == '__main__':
|
101 |
+
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|