smartinezbragado commited on
Commit
2c1c0b4
1 Parent(s): af8dd0e

Update views.py

Browse files
Files changed (1) hide show
  1. views.py +7 -14
views.py CHANGED
@@ -5,7 +5,7 @@ from bertopic import BERTopic
5
  from src.reddit import RedditBot
6
  from flask import Blueprint, render_template, request, send_file, redirect, url_for, send_from_directory
7
 
8
- DOWNLOADS_PATH = os.path.join(os.getcwd(), 'downloads')
9
 
10
  views = Blueprint(__name__, 'views')
11
  reddit = RedditBot()
@@ -43,20 +43,13 @@ def home():
43
  for t in topics_df.Topic:
44
  topics_df.loc[topics_df.Topic == t, 'Top words'] = str([w for w, p in topic_model.get_topic(t)])
45
  # Donwload topics
46
- topics_df.to_csv(os.path.join(DOWNLOADS_PATH, 'topics.csv'), index=False)
47
- send_from_directory(
48
- directory = DOWNLOADS_PATH,
49
- path = 'topics.csv',
50
- as_attachment=True,
51
- )
52
  # Download docs info
53
- docs_df = topic_model.get_document_info(subreddits_df.Text)
54
- docs_df.to_csv(os.path.join(DOWNLOADS_PATH, 'docs_with_topics_info.csv'), index=False)
55
- send_from_directory(
56
- directory = DOWNLOADS_PATH,
57
- path = 'docs_with_topics_info.csv',
58
- as_attachment=True,
59
- )
60
  return redirect(url_for('views.success'))
61
 
62
  return render_template('index.html')
 
5
  from src.reddit import RedditBot
6
  from flask import Blueprint, render_template, request, send_file, redirect, url_for, send_from_directory
7
 
8
+ # DOWNLOADS_PATH = os.path.join(os.getcwd(), 'downloads')
9
 
10
  views = Blueprint(__name__, 'views')
11
  reddit = RedditBot()
 
43
  for t in topics_df.Topic:
44
  topics_df.loc[topics_df.Topic == t, 'Top words'] = str([w for w, p in topic_model.get_topic(t)])
45
  # Donwload topics
46
+ # topics_df.to_csv(os.path.join(DOWNLOADS_PATH, 'topics.csv'), index=False)
47
+ topics_df.to_csv('topics.csv', index=False)
48
+ send_from_directory('topics.csv', as_attachment=True)
 
 
 
49
  # Download docs info
50
+ # docs_df = topic_model.get_document_info(subreddits_df.Text)
51
+ docs_df.to_csv('docs_with_topics_info.csv', index=False)
52
+ send_from_directory('docs_with_topics_info.csv', as_attachment=True)
 
 
 
 
53
  return redirect(url_for('views.success'))
54
 
55
  return render_template('index.html')