Update sbx/a/c1.py
Browse files- sbx/a/c1.py +56 -3
sbx/a/c1.py
CHANGED
|
@@ -11,14 +11,67 @@ import time
|
|
| 11 |
huggingface_user="baosa"
|
| 12 |
huggingface_id="adasdxc"
|
| 13 |
huggingface_tokon="hf_mFcVa DHkDGFFpsfsJXblWOFRCibAFWqAbW"
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
def start_simple_api(port=5000):
|
| 16 |
"""启动一个简单的 API 服务"""
|
| 17 |
app = Flask(__name__)
|
| 18 |
|
| 19 |
@app.route('/', methods=['GET'])
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# 在后台线程中启动服务
|
| 24 |
thread = threading.Thread(
|
|
|
|
| 11 |
huggingface_user="baosa"
|
| 12 |
huggingface_id="adasdxc"
|
| 13 |
huggingface_tokon="hf_mFcVa DHkDGFFpsfsJXblWOFRCibAFWqAbW"
|
| 14 |
+
# HTML 页面内容
|
| 15 |
+
HTML_PAGE = """
|
| 16 |
+
<!DOCTYPE html>
|
| 17 |
+
<html lang="zh-CN">
|
| 18 |
+
<head>
|
| 19 |
+
<meta charset="UTF-8">
|
| 20 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 21 |
+
<title>Flask 应用</title>
|
| 22 |
+
<style>
|
| 23 |
+
body {
|
| 24 |
+
font-family: Arial, sans-serif;
|
| 25 |
+
max-width: 800px;
|
| 26 |
+
margin: 0 auto;
|
| 27 |
+
padding: 20px;
|
| 28 |
+
background-color: #f5f5f5;
|
| 29 |
+
}
|
| 30 |
+
.container {
|
| 31 |
+
background: white;
|
| 32 |
+
padding: 30px;
|
| 33 |
+
border-radius: 10px;
|
| 34 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
| 35 |
+
}
|
| 36 |
+
h1 {
|
| 37 |
+
color: #333;
|
| 38 |
+
text-align: center;
|
| 39 |
+
}
|
| 40 |
+
.link {
|
| 41 |
+
display: inline-block;
|
| 42 |
+
margin: 10px;
|
| 43 |
+
padding: 10px 20px;
|
| 44 |
+
background: #007bff;
|
| 45 |
+
color: white;
|
| 46 |
+
text-decoration: none;
|
| 47 |
+
border-radius: 5px;
|
| 48 |
+
}
|
| 49 |
+
.link:hover {
|
| 50 |
+
background: #0056b3;
|
| 51 |
+
}
|
| 52 |
+
</style>
|
| 53 |
+
</head>
|
| 54 |
+
<body>
|
| 55 |
+
<div class="container">
|
| 56 |
+
<h1>🚀 Flask 应用主页</h1>
|
| 57 |
+
<p>欢迎来到 Flask 应用!这是一个简单的 HTML 页面。</p>
|
| 58 |
+
<p>您可以访问以下端点:</p>
|
| 59 |
+
<a href="/hello" class="link">/hello - JSON API</a>
|
| 60 |
+
<a href="/" class="link">/ - 主页</a>
|
| 61 |
+
</div>
|
| 62 |
+
</body>
|
| 63 |
+
</html>
|
| 64 |
+
"""
|
| 65 |
def start_simple_api(port=5000):
|
| 66 |
"""启动一个简单的 API 服务"""
|
| 67 |
app = Flask(__name__)
|
| 68 |
|
| 69 |
@app.route('/', methods=['GET'])
|
| 70 |
+
def index():
|
| 71 |
+
"""根路由,返回 HTML 页面"""
|
| 72 |
+
return render_template_string(HTML_PAGE)
|
| 73 |
+
# def home():
|
| 74 |
+
# return jsonify({'message': 'API 服务运行中', 'status': 'ok'})
|
| 75 |
|
| 76 |
# 在后台线程中启动服务
|
| 77 |
thread = threading.Thread(
|