generated from nathanwoodburn/python-webserver-template
feat: Add initial spotify restart app
All checks were successful
Build Docker / BuildImage (push) Successful in 2m10s
All checks were successful
Build Docker / BuildImage (push) Successful in 2m10s
This commit is contained in:
21
server.py
21
server.py
@@ -74,9 +74,24 @@ def wellknown(path):
|
||||
# region Main routes
|
||||
@app.route("/")
|
||||
def index():
|
||||
# Get current time in the format "dd MMM YYYY hh:mm AM/PM"
|
||||
current_datetime = datetime.now().strftime("%d %b %Y %I:%M %p")
|
||||
return render_template("index.html", datetime=current_datetime)
|
||||
return render_template("index.html")
|
||||
|
||||
|
||||
@app.route("/restart")
|
||||
def restart():
|
||||
"""
|
||||
Restart the server by redirecting to the same URL.
|
||||
This is a simple way to restart the server without needing to stop it manually.
|
||||
"""
|
||||
# Execute a `pkill spotifyd` command to stop the spotifyd process
|
||||
status = os.system("pkill spotifyd")
|
||||
# Start with a new process
|
||||
os.system("spotifyd -d 'Family Room'")
|
||||
|
||||
|
||||
|
||||
|
||||
return redirect('/')
|
||||
|
||||
|
||||
@app.route("/<path:path>")
|
||||
|
||||
Reference in New Issue
Block a user