Spaces:
Sleeping
Sleeping
| from flask import Flask, render_template, jsonify, request | |
| import os | |
| app = Flask(__name__) | |
| def index(): | |
| return render_template('index.html') | |
| 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}" | |
| }) | |
| 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) | |