Hello, i am making the system where i can search the nse and nfo in search bar and can add it to the wishlist we want but while i wrote it in flask its not working please Guide me Flask code - from flask import Flask, render_template, request, jsonify from kiteconnect import KiteConnect
app = Flask(__name__)
# Initialize Kite Connect API client api_key = '' api_secret = '' kite = KiteConnect(api_key=api_key) kite.set_access_token('') # Set your access token here
# Mock wishlist data (you can use a database instead) wishlist = []
@app.route('/search', methods=['POST']) def search_instruments(): query = request.form.get('query') # Use Zerodha API to search instruments instruments = kite.instruments('NSE') # Replace 'NSE' with 'NFO' for futures & options search_results = [instrument for instrument in instruments if query.lower() in instrument['tradingsymbol'].lower()] return jsonify(search_results)
@app.route('/add_to_wishlist', methods=['POST']) def add_to_wishlist(): instrument_token = request.form.get('instrument_token') # Check if the instrument is already in the wishlist if instrument_token not in wishlist: wishlist.append(instrument_token) return jsonify({'message': 'Instrument added to wishlist'})
Hello Vaibhav, thankyou for the response but from my side i have added the valid instrument name but still not working, any suggestion or ideas you can share?
thankyou for the response but from my side i have added the valid instrument name but still not working, any suggestion or ideas you can share?