from flask import Flask, request, render_template_string, jsonify
import requests
app = Flask(__name__)
session = requests.Session()
session.headers.update({
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
})
url = "https://fs.chowtaiseng.com/"
headers = {
"authority": "fs.chowtaiseng.com",
"method": "POST",
"path": "/",
"scheme": "https",
"accept": "*/*",
"accept-encoding": "gzip, deflate, br, zstd",
"accept-language": "zh-CN,zh;q=0.9",
"origin": "https://webchat.chowtaiseng.com",
"priority": "u=1, i",
"referer": "https://webchat.chowtaiseng.com/",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site"
}
@app.route("/", methods=["GET", "POST"])
def upload_file():
if request.method == "POST":
uploaded_file = request.files.get("file")
if not uploaded_file:
return jsonify({"error": "No file uploaded"}), 400
files = {
"name": (None, uploaded_file.filename),
"key": (None, f"im/4b2b33d-ere-ere-wereed-ee/2025/22039485855/{uploaded_file.filename}"),
"token": (None, "IoZIhomb90eKJFQSKSB7Eda7rMhezU_gaSxDXnS0:z-mMZcx1IKW4GLxMNAEUC3ptbDE=:eyJtaW1lTGltaXQiOiIhdmlkZW8vbXAydDthcHBsaWNhdGlvbi9vY3RldC1zdHJlYW0iLCJmc2l6ZU1pbiI6MSwic2NvcGUiOiJtNy1pbS1rZWZ1OmltLzRiMmI1MWIwLTMzMTYtMTFlYy05ZDVjLWNkYjRkMzQzYTBiNi8yMDI1LTAzLTI0XzE3OjExOjMxLzE3NDI4MDc0OTE2MTkvODk3MDAyODIudHh0IiwiZGVhZGxpbmUiOjE3NDI4MTEwOTF9"),
"file": (uploaded_file.filename, uploaded_file.stream)
}
try:
response = session.post(url, headers=headers, files=files)
return jsonify({
"status_code": response.status_code,
"response": response.text
}), response.status_code
except Exception as e:
return jsonify({"error": str(e)}), 500
return render_template_string("""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Upload</title>
</head>
<body>
<h1>Upload a File</h1>
<form action="/" method="post" enctype="multipart/form-data">
<label for="file">Choose a file:</label>
<input type="file" name="file" id="file" required>
<br><br>
<button type="submit">Upload</button>
</form>
</body>
</html>
""")
if __name__ == "__main__":
app.run(debug=True)