update code
parent
eb7316b837
commit
d64e709d3f
|
|
@ -4,11 +4,11 @@ from mysql.connector import Error
|
||||||
def test_mysql_connection():
|
def test_mysql_connection():
|
||||||
# MySQL 配置
|
# MySQL 配置
|
||||||
config = {
|
config = {
|
||||||
'host': '192.168.2.20',
|
'host': '192.168.1.202',
|
||||||
'port': 8006,
|
'port': 3306,
|
||||||
'user': 'mticloud',
|
'user': 'gitea',
|
||||||
'password': 'fT3KsNDahADGcWCZ',
|
'password': 'CYVVMMxrox3ThsGy',
|
||||||
'database': 'mti-cloud',
|
'database': 'gitea',
|
||||||
'charset': 'utf8mb4'
|
'charset': 'utf8mb4'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import base64
|
||||||
|
import urllib.parse
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def generate_preview_url():
|
||||||
|
# 原始 URL
|
||||||
|
origin_url = 'http://192.168.1.28:8080/prod-api/downhole-tool-system/common/files/v1/download/60cbe676ef181249af3fe2cbeea99746'
|
||||||
|
|
||||||
|
# 添加 fullfilename 参数
|
||||||
|
preview_url = origin_url
|
||||||
|
|
||||||
|
# Base64 编码
|
||||||
|
encoded_preview_url = base64.b64encode(preview_url.encode('utf-8')).decode('utf-8')
|
||||||
|
|
||||||
|
# URL 编码 Base64 编码的结果
|
||||||
|
final_url = f"http://127.0.0.1:8012/picturesPreview?urls={urllib.parse.quote(encoded_preview_url)}"
|
||||||
|
|
||||||
|
return final_url
|
||||||
|
|
||||||
|
|
||||||
|
def request_with_token():
|
||||||
|
# 生成完整的 URL
|
||||||
|
url = generate_preview_url()
|
||||||
|
|
||||||
|
print(f"完整的 URL: {url}")
|
||||||
|
|
||||||
|
# 设置请求头
|
||||||
|
headers = {
|
||||||
|
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfcm9sZV9rZXkiOiJzaHV6aXpob25neGluIiwidXNlcl9pZCI6IjEiLCJ1c2VyX25hbWUiOiJhZG1pbiIsInNjb3BlIjpbInNlcnZlciJdLCJleHAiOjE3MzQ2MDA4MDgsImp0aSI6IjJOT1hqbnRJdEh4YUJhQzRqcThJdlMtMVVSayIsImNsaWVudF9pZCI6IjFhN2JmY2M2MDI3NzRkNDk5NTkzNzU1MTFmYmIzYWYzIn0.ytexuU6OPBycL6Zoh74YTYCJ_9f-u6emsFDy4-OsDvE', # 替换为实际的 token
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
|
||||||
|
# 发起 GET 请求
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
|
||||||
|
# 处理响应
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("请求成功!")
|
||||||
|
print("响应内容:")
|
||||||
|
print(response.content) # 如果是图片/文件数据,可以保存到本地
|
||||||
|
else:
|
||||||
|
print(f"请求失败,状态码: {response.status_code}")
|
||||||
|
print("响应内容:")
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
# 执行请求
|
||||||
|
request_with_token()
|
||||||
Loading…
Reference in New Issue