26 lines
775 B
Python
26 lines
775 B
Python
from flask import Flask, render_template, request, jsonify
|
|
from solana.rpc.api import Client
|
|
|
|
app = Flask(__name__)
|
|
solana_client = Client("https://api.mainnet-beta.solana.com")
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return render_template('index.html')
|
|
|
|
@app.route('/tokens', methods=['GET'])
|
|
def get_tokens():
|
|
# Here you would add logic to fetch new tokens or token data
|
|
return jsonify(['SOL', 'USDC']) # Example token list
|
|
|
|
@app.route('/swap', methods=['POST'])
|
|
def swap_tokens():
|
|
data = request.json
|
|
token_name = data['token_name']
|
|
amount = data['amount']
|
|
# Here you would add logic to perform the token swap
|
|
return jsonify({'status': 'success', 'message': f'Swapped {amount} of {token_name}'})
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True)
|