-1

I am writing a web app using Flask, Python and Spotipy (https://spotipy.readthedocs.io/en/latest/). Spotipy requires an authentication token, that just has the user enter a url they were directed to after logging into Spotify and checks that against the url you assigned as your redirect url. It prompts them on the command line, but I want to change this to have a text box they can enter the url in, and then grab that value and pass it to the command line.

My question is, is there a way to pass a value to the command line when a prompt pops up using python?

  • Possible duplicate of [Command Line Arguments In Python](https://stackoverflow.com/questions/1009860/command-line-arguments-in-python) – Steve Byrne Aug 04 '17 at 20:59

1 Answers1

0

My question is, is there a way to pass a value to the command line when a prompt pops up using python?

Yeah, this is possible. The routine that comes to mind would resemble the following.

  1. Build a form that will prompt the user for the command/text to be passed to the command line.

  2. POST this form to the server side, which will be some function in your flask application.

  3. In the flask function grab this string that was submitted from request.POST.

  4. Use os.system to execute that string on the command line.

See also, this question if you need to capture the output of some system command you are running.

marcusshep
  • 1,916
  • 2
  • 18
  • 31
  • Not sure if it works yet because I'm working through some other errors, but #4 was what I was looking for. Thanks! – Nikki Cantrell Aug 04 '17 at 19:21
  • @NikkiCantrell If my answer has helped you in anyway, consider helping me by marking it as the accepted answer and/or upvoting :) – marcusshep Aug 04 '17 at 19:24