Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,14 @@ import requests
|
|
| 3 |
import json
|
| 4 |
import time
|
| 5 |
import random
|
|
|
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
@app.route('/')
|
| 10 |
def index():
|
| 11 |
return "text-to-image with siliconflow", 200
|
|
@@ -103,5 +108,9 @@ def handle_request():
|
|
| 103 |
except Exception as e:
|
| 104 |
return jsonify({"error": f"Internal Server Error: {str(e)}"}), 500
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
if __name__ == '__main__':
|
| 107 |
app.run(host='0.0.0.0', port=8000)
|
|
|
|
| 3 |
import json
|
| 4 |
import time
|
| 5 |
import random
|
| 6 |
+
import logging
|
| 7 |
|
| 8 |
app = Flask(__name__)
|
| 9 |
|
| 10 |
+
# 配置日志格式
|
| 11 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s')
|
| 12 |
+
logger = logging.getLogger(__name__)
|
| 13 |
+
|
| 14 |
@app.route('/')
|
| 15 |
def index():
|
| 16 |
return "text-to-image with siliconflow", 200
|
|
|
|
| 108 |
except Exception as e:
|
| 109 |
return jsonify({"error": f"Internal Server Error: {str(e)}"}), 500
|
| 110 |
|
| 111 |
+
finally:
|
| 112 |
+
# 记录请求的 model 和 被命中的 token
|
| 113 |
+
logger.info(f'"POST /ai/v1/chat/completions HTTP/1.1" "model: {model}" "token: {selected_token}" "status: {response.status_code}" -')
|
| 114 |
+
|
| 115 |
if __name__ == '__main__':
|
| 116 |
app.run(host='0.0.0.0', port=8000)
|