-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
52 lines (46 loc) · 1.5 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Routes and views for the flask application.
"""
from datetime import datetime
from flask import render_template
from __init__ import app
from songdictionary import getSentValue
from songdictionary import getSongUrlFromValue
from flask import request
from flask import abort, redirect, url_for
from html_rip import link_or_nah, to_text, get_html, visible
from mood import determineSubject
if __name__ == '__main__':
app.debut = True
app.run(debug=True)
@app.route('/', methods=['POST', 'GET'])
def home():
if request.method == 'POST':
if request.form['soundType'] == 'Song':
text = request.form['weblink']
return redirect(url_for('music', text=text))
else:
text = request.form['weblink']
return redirect(url_for('beats', text=text))
else:
return render_template('index.html')
@app.route('/music')
def music():
text = request.args['text']
if link_or_nah(text):
text = to_text(text)
else:
text = text
sentiment = float(determineSubject(text))
value = getSentValue(sentiment)
songUrl = getSongUrlFromValue(sentiment)
return render_template('music.html', text=text, sentiment = sentiment, songUrl=songUrl, value=value)
@app.route('/beats')
def beats():
text = request.args['text']
if link_or_nah(text):
text = to_text(text)
else:
text = text
sentiment = float(determineSubject(text))
return render_template('beats.html', soundtype="beat", sentiment = sentiment)