Spotipy service on WSGI Flask Server

36 Views Asked by At

I am currently working on a WebApp for music control on an existing WSGI server I have. If I run the debug main.py file directly on the server with ssh command it all works perfecly fine but when I want to access the server via the normal way of the WSGI script i get HTTP Error 500.

main.py:

if __name__ == "__main__":
    from webapp import create_app
    app = create_app()

    app.run(debug=True)

service.wsgi:

import sys
import os

sys.path.insert(0, '[path to files]')
from webapp import create_app

application = create_app()

The WSGI error Log sais the following:

[Thu Jun 15 23:51:38.811713 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] mod_wsgi (pid=1652617): Failed to exec Python script file '.../player_service.wsgi'.
[Thu Jun 15 23:51:38.811769 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] mod_wsgi (pid=1652617): Exception occurred processing WSGI script '.../player_service.wsgi'.
[Thu Jun 15 23:51:38.812458 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] Traceback (most recent call last):
[Thu Jun 15 23:51:38.812488 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File "/usr/local/lib/python3.10/dist-packages/spotipy/oauth2.py", line 115, in _get_user_input
[Thu Jun 15 23:51:38.812494 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     return raw_input(prompt)
[Thu Jun 15 23:51:38.812509 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] NameError: name 'raw_input' is not defined
[Thu Jun 15 23:51:38.812516 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] 
[Thu Jun 15 23:51:38.812521 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] During handling of the above exception, another exception occurred:
[Thu Jun 15 23:51:38.812525 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] 
[Thu Jun 15 23:51:38.812530 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] Traceback (most recent call last):
[Thu Jun 15 23:51:38.812557 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File ".../player_service.wsgi", line 5, in <module>
[Thu Jun 15 23:51:38.812562 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     from webapp import create_app
[Thu Jun 15 23:51:38.812567 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File ".../webapp/__init__.py", line 17, in <module>
[Thu Jun 15 23:51:38.812571 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     spotify = Spotify.Spotify(
[Thu Jun 15 23:51:38.812577 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File ".../webapp/Spotify.py", line 55, in __init__
[Thu Jun 15 23:51:38.812581 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     self.__token = self.__auth_handler.get_access_token()
[Thu Jun 15 23:51:38.812586 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File "/usr/local/lib/python3.10/dist-packages/spotipy/oauth2.py", line 535, in get_access_token
[Thu Jun 15 23:51:38.812591 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     "code": code or self.get_auth_response(),
[Thu Jun 15 23:51:38.812596 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File "/usr/local/lib/python3.10/dist-packages/spotipy/oauth2.py", line 499, in get_auth_response
[Thu Jun 15 23:51:38.812601 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     return self._get_auth_response_interactive(open_browser=open_browser)
[Thu Jun 15 23:51:38.812607 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File "/usr/local/lib/python3.10/dist-packages/spotipy/oauth2.py", line 450, in _get_auth_response_interactive
[Thu Jun 15 23:51:38.812611 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     response = self._get_user_input(prompt)
[Thu Jun 15 23:51:38.812616 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]   File "/usr/local/lib/python3.10/dist-packages/spotipy/oauth2.py", line 117, in _get_user_input
[Thu Jun 15 23:51:38.812620 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx]     return input(prompt)
[Thu Jun 15 23:51:38.812629 2023] [wsgi:error] [pid 1652617] [client xxx.xxx.xxx:xxxx] EOFError: EOF when reading a line

my guess is that is has something to do withe the spotify authorization because normally it would wnat you to input a link to authorize in the commandline.

Does anyone have an idea how i could make this work?

0

There are 0 best solutions below