Skip to content

Commit

Permalink
Templates reformed
Browse files Browse the repository at this point in the history
  • Loading branch information
ramanaditya committed Oct 12, 2020
1 parent ddfbe5a commit 50e9fb7
Show file tree
Hide file tree
Showing 33 changed files with 9,187 additions and 21 deletions.
42 changes: 21 additions & 21 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from apps.process_data import ProcessData, Results
from apps.tweets import Twitter
from loguru import logger
from flask import render_template

logger.add(
"logs/twitstat.log",
Expand All @@ -15,28 +16,27 @@
backtrace=True,
diagnose=True,
)
app = Flask(__name__)
app = Flask(__name__,
static_url_path='',
static_folder='./static',
template_folder='./templates')


@app.route("/", methods=["GET"])
def analyze_tweets():
logger.info("Analyze tweets initiated")
twitter = Twitter()
top_trends = twitter.get_top_trends()
logger.info(f"Top trends now are {top_trends}")
trending_tweets = twitter.get_trending_tweets(top_trends[0]["name"])
df = pd.DataFrame(trending_tweets)
esp = 1.29
df, clusters_count = ProcessData().cluster(esp, df)
res, clusters_count = Results(df).get_result()
logger.info(f"Clusters: {clusters_count}")
result = {}
for ind, row in res.iterrows():
result[ind] = dict(row)
response = dict()
response["cluserts_count"] = clusters_count.to_json()
response["result"] = result
return jsonify(response)

if __name__ == "__main__":
app.run()
# twitter = Twitter()
# top_trends = twitter.get_top_trends()
# logger.info(f"Top trends now are {top_trends}")
# trending_tweets = twitter.get_trending_tweets(top_trends[0]["name"])
# df = pd.DataFrame(trending_tweets)
# esp = 1.29
# df, clusters_count = ProcessData().cluster(esp, df)
# res, clusters_count = Results(df).get_result()
# logger.info(f"Clusters: {clusters_count}")
# result = {}
# for ind, row in res.iterrows():
# result[ind] = dict(row)
# response = dict()
# response["cluserts_count"] = clusters_count.to_json()
# response["result"] = result
return render_template('index.html')
7 changes: 7 additions & 0 deletions static/css/bootstrap.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 50e9fb7

Please sign in to comment.