forked from CopyBot/sptnr
refactor: server.py
This commit is contained in:
+2
-2
@@ -10,8 +10,8 @@ COPY . .
|
||||
# Install any needed packages specified in requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Expose port 3333 for the Flask app
|
||||
EXPOSE 3333
|
||||
# Expose port 5000 for the Flask app
|
||||
EXPOSE 5000
|
||||
|
||||
# Set the entrypoint to Python
|
||||
ENTRYPOINT ["python", "sptnr.py"]
|
||||
|
||||
@@ -9,6 +9,12 @@ services:
|
||||
# Uncomment the next line to build the Docker image locally
|
||||
# build: .
|
||||
|
||||
# Uncomment the next line to run the script
|
||||
# entrypoint: ["python", "sptnr.py"]
|
||||
|
||||
# Uncomment the next line to start the web server
|
||||
# entrypoint: ["gunicorn", "-b", "0.0.0.0:5000", "web_server:sptnr_web_server"]
|
||||
|
||||
environment:
|
||||
- NAV_BASE_URL=your_navidrome_server_url
|
||||
- NAV_USER=your_navidrome_username
|
||||
@@ -20,9 +26,4 @@ services:
|
||||
volumes:
|
||||
- ./data:/usr/src/app/data
|
||||
ports:
|
||||
- "3333:3333"
|
||||
# Uncomment the next line to just run the script
|
||||
# entrypoint: ["python", "sptnr.py"]
|
||||
|
||||
# Uncomment the next line to start the web server
|
||||
# entrypoint: ["python", "web_server.py"]
|
||||
- "3333:5000"
|
||||
|
||||
@@ -7,7 +7,7 @@ import functools
|
||||
|
||||
load_dotenv()
|
||||
|
||||
sptnr_web_server = Flask(__name__)
|
||||
sptnr = Flask(__name__)
|
||||
WEB_API_KEY = os.getenv("WEB_API_KEY")
|
||||
ENABLE_WEB_API_KEY = os.getenv("ENABLE_WEB_API_KEY", "True") == "True"
|
||||
LOG_DIR = "data/logs"
|
||||
@@ -27,7 +27,7 @@ def run_script(cmd):
|
||||
subprocess.run(cmd)
|
||||
|
||||
|
||||
@sptnr_web_server.route("/process", methods=["GET", "POST"])
|
||||
@sptnr.route("/process", methods=["GET", "POST"])
|
||||
@api_key_required
|
||||
def process_request():
|
||||
cmd = ["python3", "sptnr.py"]
|
||||
@@ -54,7 +54,7 @@ def process_request():
|
||||
return jsonify({"message": "Processing started"})
|
||||
|
||||
|
||||
@sptnr_web_server.route("/logs")
|
||||
@sptnr.route("/logs")
|
||||
@api_key_required
|
||||
def list_logs():
|
||||
try:
|
||||
@@ -67,7 +67,7 @@ def list_logs():
|
||||
return f"An error occurred: {e}", 500
|
||||
|
||||
|
||||
@sptnr_web_server.route("/logs/<filename>")
|
||||
@sptnr.route("/logs/<filename>")
|
||||
@api_key_required
|
||||
def view_log(filename):
|
||||
try:
|
||||
@@ -86,4 +86,4 @@ def view_log(filename):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sptnr_web_server.run(debug=False, host="0.0.0.0", port=3333)
|
||||
sptnr.run(debug=False, host="0.0.0.0", port=3333)
|
||||
Reference in New Issue
Block a user