Update sbx/b.py
Browse files
sbx/b.py
CHANGED
|
@@ -8,8 +8,64 @@ import urllib.parse
|
|
| 8 |
def jupyter():
|
| 9 |
os.system('jupyter lab --ip=0.0.0.0 --port=8002 --no-browser --allow-root --notebook-dir=/data --NotebookApp.token=qilan --ServerApp.disable_check_xsrf=True')
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# threading.Thread(target=jupyter, daemon=True).start()
|
| 12 |
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
@app.route('/hello', methods=['GET'])
|
| 15 |
def hello():
|
|
@@ -25,7 +81,7 @@ def greet():
|
|
| 25 |
def get_log_content():
|
| 26 |
try:
|
| 27 |
# 使用绝对路径读取文件
|
| 28 |
-
file_path = '/data/
|
| 29 |
|
| 30 |
# 检查文件是否存在
|
| 31 |
if not os.path.exists(file_path):
|
|
|
|
| 8 |
def jupyter():
|
| 9 |
os.system('jupyter lab --ip=0.0.0.0 --port=8002 --no-browser --allow-root --notebook-dir=/data --NotebookApp.token=qilan --ServerApp.disable_check_xsrf=True')
|
| 10 |
|
| 11 |
+
|
| 12 |
+
# HTML 页面内容
|
| 13 |
+
HTML_PAGE = """
|
| 14 |
+
<!DOCTYPE html>
|
| 15 |
+
<html lang="zh-CN">
|
| 16 |
+
<head>
|
| 17 |
+
<meta charset="UTF-8">
|
| 18 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 19 |
+
<title>Flask 应用</title>
|
| 20 |
+
<style>
|
| 21 |
+
body {
|
| 22 |
+
font-family: Arial, sans-serif;
|
| 23 |
+
max-width: 800px;
|
| 24 |
+
margin: 0 auto;
|
| 25 |
+
padding: 20px;
|
| 26 |
+
background-color: #f5f5f5;
|
| 27 |
+
}
|
| 28 |
+
.container {
|
| 29 |
+
background: white;
|
| 30 |
+
padding: 30px;
|
| 31 |
+
border-radius: 10px;
|
| 32 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
| 33 |
+
}
|
| 34 |
+
h1 {
|
| 35 |
+
color: #333;
|
| 36 |
+
text-align: center;
|
| 37 |
+
}
|
| 38 |
+
.link {
|
| 39 |
+
display: inline-block;
|
| 40 |
+
margin: 10px;
|
| 41 |
+
padding: 10px 20px;
|
| 42 |
+
background: #007bff;
|
| 43 |
+
color: white;
|
| 44 |
+
text-decoration: none;
|
| 45 |
+
border-radius: 5px;
|
| 46 |
+
}
|
| 47 |
+
.link:hover {
|
| 48 |
+
background: #0056b3;
|
| 49 |
+
}
|
| 50 |
+
</style>
|
| 51 |
+
</head>
|
| 52 |
+
<body>
|
| 53 |
+
<div class="container">
|
| 54 |
+
<h1>🚀 Flask 应用主页</h1>
|
| 55 |
+
<p>欢迎来到 Flask 应用!这是一个简单的 HTML 页面。</p>
|
| 56 |
+
<p>您可以访问以下端点:</p>
|
| 57 |
+
<a href="/hello" class="link">/hello - JSON API</a>
|
| 58 |
+
<a href="/" class="link">/ - 主页</a>
|
| 59 |
+
</div>
|
| 60 |
+
</body>
|
| 61 |
+
</html>
|
| 62 |
+
"""
|
| 63 |
# threading.Thread(target=jupyter, daemon=True).start()
|
| 64 |
app = Flask(__name__)
|
| 65 |
+
@app.route('/')
|
| 66 |
+
def index():
|
| 67 |
+
"""根路由,返回 HTML 页面"""
|
| 68 |
+
return render_template_string(HTML_PAGE)
|
| 69 |
|
| 70 |
@app.route('/hello', methods=['GET'])
|
| 71 |
def hello():
|
|
|
|
| 81 |
def get_log_content():
|
| 82 |
try:
|
| 83 |
# 使用绝对路径读取文件
|
| 84 |
+
file_path = '/data/app.log'
|
| 85 |
|
| 86 |
# 检查文件是否存在
|
| 87 |
if not os.path.exists(file_path):
|