Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
john-s4d committed Feb 7, 2025
2 parents 3038cfc + 13fbe66 commit f491a42
Show file tree
Hide file tree
Showing 10 changed files with 659 additions and 267 deletions.
89 changes: 89 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from flask import Flask, render_template, jsonify, request
from update_values import update_values, cryptocurrencies
import threading
import time
import json

app = Flask(__name__)


def update_cryptocurrencies():
while True:
update_values()
time.sleep(0.5)

def determine_region(crypto):
regions = []
if "mindshare" in crypto and crypto["mindshare"] > 7:
regions.append("Popular on Social Media")
if "marketCap" in crypto and crypto["marketCap"] > 7:
regions.append("Large Market Value")
if "liquidity" in crypto and crypto["liquidity"] > 7:
regions.append("Easy to Buy/Sell")
if "price" in crypto and crypto["price"] > 7:
regions.append("Stable Price")
if "averageEngagementsCount" in crypto and crypto["averageEngagementsCount"] > 7:
regions.append("High Community Engagement")
if not regions:
regions.append("Other")
return regions

@app.route('/')
def hello_world():
regions = {"Popular on Social Media": [], "Large Market Value": [], "Easy to Buy/Sell": [], "Stable Price": [], "High Community Engagement": [], "Other": []}
for crypto in cryptocurrencies:
crypto_regions = determine_region(crypto)
for region in crypto_regions:
regions[region].append(crypto)
return render_template('index.html', regions=regions)

@app.route('/data')
def data():
print("Serving data:", cryptocurrencies) # Log the data being served
return jsonify(cryptocurrencies)

@app.route('/update', methods=['POST'])
def update():
market_cap_divisor = 100000000000000
liquidity_divisor = 100000000
price_divisor = 1000
engagements_divisor = 100000
data = request.json
for crypto in cryptocurrencies:
if crypto['agentName'] == data['name']:
crypto['mindshare'] = data['mindshare']
crypto['marketCap'] = data['marketCap'] / market_cap_divisor
crypto['liquidity'] = data['liquidity'] / liquidity_divisor
crypto['price'] = data['price']
crypto['averageEngagementsCount'] = data['averageEngagementsCount']
return jsonify(crypto)
return jsonify({'error': 'Crypto not found'}), 404

@app.route('/dashboard')
def dashboard():
return render_template('dashboard.html')

@app.route('/dashboard_update')
def dashboard_update():
return render_template('Dashboard_Update.html')

@app.route('/check_update')
def check_update():
with open('update_flag.json', 'r') as f:
update_flag = json.load(f)
if update_flag.get("updated"):
with open('update_flag.json', 'w') as f:
json.dump({"updated": False}, f)
return jsonify({"updated": True})
return jsonify({"updated": False})


@app.route('/get_btc_price')
def get_btc_price():
# Dummy data for BTC price. Replace this with real API calls later.
return jsonify({"price": "$45,000"})
if __name__ == '__main__':
update_thread = threading.Thread(target=update_cryptocurrencies)
update_thread.daemon = True
update_thread.start()
app.run(debug=True, port=5008)
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ python-dotenv
langchain
openai
langchain_community
langchain_openai
langchain_openai
python-dotenv
langchain_community
Binary file added static/cookie-full.webp
Binary file not shown.
Binary file added static/cookie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/cropped-Agience-11-cropped-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f491a42

Please sign in to comment.