Spaces:
Paused
Paused
Kastg commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import psutil
|
|
| 4 |
import time
|
| 5 |
import datetime
|
| 6 |
import json
|
|
|
|
| 7 |
|
| 8 |
app = Flask(__name__)
|
| 9 |
|
|
@@ -32,7 +33,13 @@ def ai():
|
|
| 32 |
|
| 33 |
@app.route('/ai/<path:filename>')
|
| 34 |
def ai_file(filename):
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
@app.route('/info')
|
| 38 |
def info():
|
|
@@ -69,14 +76,6 @@ def count():
|
|
| 69 |
'visitor_total': visitor_total
|
| 70 |
})
|
| 71 |
|
| 72 |
-
@app.route('/reset')
|
| 73 |
-
def reset_visitor_count():
|
| 74 |
-
global visitor_count, visitor_today, last_update_date
|
| 75 |
-
visitor_count = 0
|
| 76 |
-
visitor_today = 0
|
| 77 |
-
last_update_date = datetime.datetime.now().date()
|
| 78 |
-
return jsonify({'visitor_count': visitor_count, 'visitor_today': visitor_today})
|
| 79 |
-
|
| 80 |
# Define the status route
|
| 81 |
@app.route('/status')
|
| 82 |
def status():
|
|
|
|
| 4 |
import time
|
| 5 |
import datetime
|
| 6 |
import json
|
| 7 |
+
import subprocess
|
| 8 |
|
| 9 |
app = Flask(__name__)
|
| 10 |
|
|
|
|
| 33 |
|
| 34 |
@app.route('/ai/<path:filename>')
|
| 35 |
def ai_file(filename):
|
| 36 |
+
if filename.endswith('.py'):
|
| 37 |
+
with open(os.path.join(static_dir, 'ai', filename), 'r') as f:
|
| 38 |
+
code = f.read()
|
| 39 |
+
output = subprocess.check_output(["python", "-c", code], shell=True, stderr=subprocess.STDOUT)
|
| 40 |
+
return output.decode('utf-8')
|
| 41 |
+
else:
|
| 42 |
+
return send_from_directory(os.path.join(static_dir, 'ai'), filename)
|
| 43 |
|
| 44 |
@app.route('/info')
|
| 45 |
def info():
|
|
|
|
| 76 |
'visitor_total': visitor_total
|
| 77 |
})
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
# Define the status route
|
| 80 |
@app.route('/status')
|
| 81 |
def status():
|