Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234567893 unmodified lines131415161718192021222324from flask import Flask, jsonifyfrom price_fetcher import fetch_pricefrom trend_engine import detect_trendapp = Flask(__name__)@app.route("/", methods=["GET"])def home():return jsonify({3 unmodified lines@app.route("/status", methods=["GET"])def status():price = fetch_price()trend = detect_trend(price)return jsonify({"price": round(price, 4),"trend": trend})if __name__ == "__main__":app.run(host="0.0.0.0", port=7860)123456789101112131415161718192021222324252627283 unmodified lines32333435363738394041from flask import Flask, jsonifyfrom price_fetcher import fetch_pricefrom trend_engine import detect_trendfrom aws_logger import upload_to_s3import threadingimport timefrom datetime import datetimeapp = Flask(__name__)latest_signal = {"price": 0.0, "trend": "⏳ Waiting..."}def background_refresh():global latest_signalwhile True:price = fetch_price()trend = detect_trend(price)latest_signal = {"price": round(price, 4),"trend": trend,"timestamp": datetime.utcnow().isoformat()}upload_to_s3(latest_signal)time.sleep(60)@app.route("/", methods=["GET"])def home():return jsonify({3 unmodified lines@app.route("/status", methods=["GET"])def status():return jsonify(latest_signal)if __name__ == "__main__":thread = threading.Thread(target=background_refresh)thread.daemon = Truethread.start()app.run(host="0.0.0.0", port=7860)
app.py+23-6