forked from AtmegaBuzz/Moodify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
52 lines (38 loc) · 1.25 KB
/
app.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
from distutils.log import debug
from flask import Flask , request,render_template,flash,redirect
from main import run_classifier
import os
import random
from werkzeug.utils import secure_filename
UPLOAD_FOLDER = os.path.join(os.getcwd(),"images")
app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
token = ""
@app.route('/',methods=["GET","POST"])
def home():
if request.method=="POST":
files = request.files
image = files.get('file')
if image.filename == '':
flash("no image selected")
return redirect(request.url)
else:
filename = secure_filename(image.filename)
image.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
image_path = os.path.join(UPLOAD_FOLDER,filename)
mood = run_classifier(image_path)
return render_template('index.html')
@app.route('/music',methods=["GET","POST"])
def music():
pagetitle = "Music",
name = "swapnil"
hackathon = "make4thon"
link = "htpps://dasd"
context = {
"pagetitle":pagetitle,
"name":name,
"hackathon":hackathon
}
return render_template('musicplayer.html',context=context)
if __name__=='__main__':
app.run(debug=True)