Trae Assistant
优化部署
c64589d
raw
history blame contribute delete
829 Bytes
from flask import Flask, render_template, jsonify, request
import os
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/api/calculate', methods=['POST'])
def calculate():
data = request.json or {}
rate = float(data.get('hourlyRate', 0))
duration = float(data.get('duration', 0))
currency = data.get('currency', 'CNY')
hours = duration / 3600.0
earnings = hours * rate
return jsonify({
'earnings': round(earnings, 2),
'currency': currency,
'hours': round(hours, 4),
'formatted_earnings': f"{earnings:,.2f} {currency}"
})
@app.route('/health')
def health():
return jsonify(status="ok"), 200
if __name__ == '__main__':
port = int(os.environ.get("PORT", "7860"))
app.run(host='0.0.0.0', port=port)