Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added project/__pycache__/app.cpython-37.pyc
Binary file not shown.
Binary file added project/__pycache__/listings.cpython-37.pyc
Binary file not shown.
Binary file added project/__pycache__/main.cpython-37.pyc
Binary file not shown.
201 changes: 201 additions & 0 deletions project/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
from flask import Flask, render_template,redirect,request,url_for,flash
import sqlite3 as db
import feedparser
from indicoio import config, text_tags
from bs4 import BeautifulSoup as bs
import requests

config.api_key = "cfa7082e0a98abd1aaf9f085f9a850b1"

app = Flask(__name__)
app.debug = True

feedt = "https://www.sciencedaily.com/rss/top/technology.xml"
feedh = "http://feeds.bbci.co.uk/news/health/rss.xml"
feede = "http://feeds.bbci.co.uk/news/science_and_environment/rss.xml"
feedsp = "https://www.sciencedaily.com/rss/space_time.xml"

# login_manager = LoginManager()
# login_manager.init_app(app)



def sql_query(query):
connection = db.connect("brainmap.db")
connection.row_factory =db.Row
cursor = connection.cursor()
cursor.execute(query)
rows = cursor.fetchall()
connection.close()
return rows

def sql_insert(name,username,password,emailid,h,s,t,e):
connection = db.connect("brainmap.db")
connection.row_factory =db.Row
cursor = connection.cursor()
cursor.execute('''INSERT INTO User (Name,Emailid,Username,Password,Space,Technology,Environment,Healthcare,Credits)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''',(name,emailid,username,password,s,t,e,h,30))
connection.commit()

connection.close()
return 1







def thresholded(tags, minimum):
"""
Remove all tags with probability less than `minimum`
"""
return dict((category, prob) for category, prob in tags.items()
if prob > minimum)

def likely_tag(tags, minimum=0.1):
"""
Threshold tags, then get the tag with the highest probability.
If no tag probability exceeds the minimum, return the string 'none'
"""
trimmed = thresholded(tags, minimum) or {'none': 0}
return max(trimmed, key=lambda key: trimmed[key])

def parsed(entry):
"""
Strip unnecessary content from the return of feedparser,
and augment with the output of indico's `text_tags` API
"""
return {
'title': entry['title'],
'link': entry['link'],
'tag': likely_tag(entry['tags'])
}

@app.route('/')
def main():
entries = []
entry = get_feeds(feede)
entries.extend(entry)
entry = get_feeds(feedsp)
entries.extend(entry)
entry = get_feeds(feedt)
entries.extend(entry)
entry = get_feeds(feedh)
entries.extend(entry)
return render_template('index.html', entries=entries)


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

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







@app.route('/log',methods=['GET','POST'])
def log():
if(request.method=="GET"):
res = sql_query('''SELECT *FROM User''')
msg = 'SELECT * FROM User'
return render_template('log.html',data = res,msg = msg)

@app.route('/signup/',methods=['GET','POST'])
def signup():
# if(request.method=="POST"):
return render_template('signup.html')


def get_feeds(feed):
entries = feedparser.parse(feed)['entries']
titles = [entry.get('title') for entry in entries]
#title_tags = text_tags(titles)
for entry, tags in zip(entries, titles):
entry['tags'] = tags
entries = [entry for entry in entries]
return entries


@app.route('/signed_in',methods=['GET','POST'])
def signed_in():
if(request.method=="POST"):
name = request.form['name']
username = request.form['username']
emailid = request.form['email']
password = request.form['password']
checklist = request.form.getlist('preference')
h = 0
s = 0
t= 0
e = 0
if 'envi' in checklist:
e = 1
if 'space' in checklist:
s = 1
if 'tech' in checklist:
t = 1
if 'health' in checklist:
h = 1
sql_insert(name,username,password,emailid,h,s,t,e)
print(checklist)
entries = []
if(e==1):
print("feed env")
entry = get_feeds(feede)
entries.extend(entry)
if(s==1):
print("feed space")
entry = get_feeds(feedsp)
entries.extend(entry)
if(t==1):
print("feed tech")
entry = get_feeds(feedt)
entries.extend(entry)
if(h==1):
print("feed health")
entry = get_feeds(feedh)
entries.extend(entry)

return render_template('index.html',entries=entries)

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

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


@app.route('/page3/<topicName>')
def page3(topicName):
base = "https://www.youtube.com/results?search_query="
qstring = topicName

r = requests.get(base+qstring)
print(r)
page = r.text
soup=bs(page,'html.parser')

vids = soup.findAll('a',attrs={'class':'yt-uix-tile-link'})
print(vids)
videolist=[]
c = 0
for v in vids:
if(c<6):
tmp = 'https://www.youtube.com' + v['href']
tmp = tmp.replace("watch?v=", "embed/")
videolist.append(tmp)
c = c+1
return render_template('page3.html',video1 = videolist,topicName = topicName)

if __name__ == '__main__':
app.run()
Binary file added project/brain1.sqlite3
Binary file not shown.
Binary file added project/brainmap.db
Binary file not shown.
27 changes: 27 additions & 0 deletions project/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sqlite3 as db
connection = db.connect("brainmap.db")
cursor = connection.cursor()

cursor.execute('''CREATE TABLE User
(Name TEXT,
Emailid TEXT,
Username TEXT,
Password TEXT,
Space INT,
Technology INT,
Environment INT,
Healthcare INT,
Credits INT,
PRIMARY KEY(Username)
)
''')


cursor.execute('''INSERT INTO User (Name,Emailid,Username,Password,Space,Technology,Environment,Healthcare,Credits)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''',['Joe','joe6161@gmail.com','joe','abc',1,1,0,0,30])

connection.commit()


connection.close()
84 changes: 84 additions & 0 deletions project/env/bin/activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly


if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

deactivate () {
unset -f pydoc >/dev/null 2>&1

# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi

# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi

if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi

unset VIRTUAL_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}

# unset irrelevant variables
deactivate nondestructive

VIRTUAL_ENV="/home/miriam-john/Documents/tutorilals/extrastuff/flask/env"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH

# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1-}"
if [ "x" != x ] ; then
PS1="${PS1-}"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}"
fi
export PS1
fi

# Make sure to unalias pydoc if it's already there
alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true

pydoc () {
python -m pydoc "$@"
}

# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi
55 changes: 55 additions & 0 deletions project/env/bin/activate.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.

set newline='\
'

alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'

# Unset irrelevant variables.
deactivate nondestructive

setenv VIRTUAL_ENV "/home/miriam-john/Documents/tutorilals/extrastuff/flask/env"

set _OLD_VIRTUAL_PATH="$PATH:q"
setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"



if ("" != "") then
set env_name = ""
else
set env_name = '('"$VIRTUAL_ENV:t:q"') '
endif

if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
set do_prompt = "1"
else
set do_prompt = "0"
endif
else
set do_prompt = "1"
endif

if ( $do_prompt == "1" ) then
# Could be in a non-interactive environment,
# in which case, $prompt is undefined and we wouldn't
# care about the prompt anyway.
if ( $?prompt ) then
set _OLD_VIRTUAL_PROMPT="$prompt:q"
if ( "$prompt:q" =~ *"$newline:q"* ) then
:
else
set prompt = "$env_name:q$prompt:q"
endif
endif
endif

unset env_name
unset do_prompt

alias pydoc python -m pydoc

rehash
Loading