Add backend

This commit is contained in:
Pavle Portic 2018-03-21 02:28:28 +01:00
parent 2288cff13b
commit a22822f719
4 changed files with 66 additions and 0 deletions

1
backend/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__

47
backend/run.py Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env python
from flask import Flask
from subprocess import call
app = Flask(__name__)
@app.route('/mute')
def mute():
call(['pactl', 'set-sink-mute', '0', 'toggle'])
return ''
@app.route('/vol_down')
def vol_down():
call(['pactl', 'set-sink-volume', '0', '-5%'])
return ''
@app.route('/vol_up')
def vol_up():
call(['pactl', 'set-sink-volume', '0', '+5%'])
return ''
@app.route('/prev')
def prev():
call(['cmus-remote', '-p'])
return ''
@app.route('/play')
def play():
call(['cmus-remote', '-u'])
return ''
@app.route('/next')
def next():
call(['cmus-remote', '-n'])
return ''
if __name__ == '__main__':
app.run()

12
backend/wsgi.ini Normal file
View File

@ -0,0 +1,12 @@
[uwsgi]
plugins = python
module = wsgi:app
socket = /srv/http/i3control/i3control.sock
master = true
threads = 2
stats = 127.0.0.1:9191
vacuum = true
die-on-term = true

6
backend/wsgi.py Normal file
View File

@ -0,0 +1,6 @@
from run import app
if __name__ == "__main__":
app.run()