from fastapi import FastAPI from vnstock import Vnstock app = FastAPI() vnstock = Vnstock() @app.get("/") def root(): return {"message": "🇻🇳 Vietnam Stock API từ Hugging Face đã sẵn sàng!"} @app.get("/hello") def say_hello(): return {"message": "Chào bạn từ FastAPI chạy trên Hugging Face!"} @app.get("/price/{symbol}") def get_realtime_price(symbol: str): try: stock = vnstock.stock(symbol=symbol, source="VCI") data = stock.quote.realtime() return data except Exception as e: return {"error": str(e)}