def post_request(): #print request.data #print request.get_json url = dict(request.form).keys()[0].partition("?")[0] returnedData = musicController.parseURL(url, download=True) x = vars(returnedData) main.addToDB(x) songController.add(x) return 'This works'
def index(): data = request.get_json() url = data['url'] returnedData = musicController.parseURL(url, download=True) # raw_input(vars(returnedData)) #returnedData = parseURL(url, download=True) x = vars(returnedData) main.addToDB(x) songController.add(x) return 'This works'
def post_request(): print request.form print request.get_json() print dict(request.form) #print request.data #print request.get_json if 'music.apple' in dict(request.form).keys()[0]: val = ''.join( re.findall( "\d+", str(dict(request.form)[dict(request.form).keys()[0]][0]))) print("VAL ") print(val) url = ''.join(dict(request.form).keys()[0] + val) print("URL FIRST: {}".format(url)) else: url = dict(request.form).keys()[0].partition("?")[0] print("URL: {}".format(url)) returnedData = musicController.parseURL(url, download=True) x = vars(returnedData) main.addToDB(x) songController.add(x) return 'This works'
from flask import Flask, render_template, request, url_for, redirect, Markup, jsonify, make_response, send_from_directory, session, send_file import musicController from flask_sockets import Sockets import datetime import time import main import random import re app = Flask(__name__, static_url_path='/static') sockets = Sockets(app) songController = musicController.controller() for val in musicController.EXAMPLE_SONGS: songInfo = musicController.parseURL(val) songController.add(vars(songInfo)) ''' for i, val in enumerate(songController.order): print("{} - {}".format(i, val['song'])) for i in range(5): song = songController.play_next() print("Playing: {} | Next Song: {}".format(song, songController.get_next())) ''' @app.route("/postRequest", methods=["POST"]) def post_request(): print request.form print request.get_json()