-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (25 loc) · 801 Bytes
/
main.py
File metadata and controls
33 lines (25 loc) · 801 Bytes
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
from flask import Flask, request, render_template, send_file
from spotify_test import playlist_stats
from flask_cors import CORS, cross_origin
app = Flask(__name__)
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
@app.route("/")
@cross_origin()
def hello_word():
return render_template("index.html")
@app.post("/stats")
@cross_origin()
def playlistStats():
playlist = request.form["nm"]
playlist_stats(playlist)
return send_file('templates/images/new_plot.pdf',
mimetype='application/pdf',
attachment_filename='Stats.pdf',
as_attachment=True)
@app.errorhandler(Exception)
def not_found(e):
return render_template("404.html")
if __name__ == "__main__":
app.run(debug= True)