From a56c78b24adaa7dbae673d4f3bd210834e25acfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Bedn=C3=A1rik?= Date: Fri, 13 Dec 2024 09:58:45 +0100 Subject: [PATCH] Use env variables Fix readme Change default port --- .gitignore | 2 -- README.md | 9 +++++---- config.py | 8 ++++++++ config.template | 8 -------- wsgi.py | 5 ++++- 5 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 config.py delete mode 100644 config.template diff --git a/.gitignore b/.gitignore index ebd768b..d82269f 100644 --- a/.gitignore +++ b/.gitignore @@ -130,5 +130,3 @@ cython_debug/ # IDE files .idea/ - -config.py diff --git a/README.md b/README.md index 9b0a68f..53f694c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # OpenSpoolMan Use any filament like Bambu filaments with automatic recognition and filament usage updates in your AMS! -No need for any special hardware, just your phone and some NFC tags! +No need for cloud or any special hardware, just your phone and some NFC tags! Similar functionality to https://github.com/spuder/OpenSpool using only your phone, server and NFC tags integrated with SpoolMan -Everything works locally without cloud access, you can use init_bambulab.py script to access your PRINTER_ID and PRINTER_CODE if it is not available on your printer. +Everything works locally without cloud access, you can use scripts/init_bambulab.py script to access your PRINTER_ID and PRINTER_CODE if it is not available on your printer. What you need: - Android Phone with Chrome web browser or iPhone (manual process much more complicated) @@ -22,7 +22,7 @@ How to setup: - set PRINTER_CODE - On your printer clicking on Setting -> Lan Only Mode -> Access Code (you _don't_ need to enable the LAN Only Mode) - set PRINTER_IP - On your printer clicking on Setting -> Lan Only Mode -> IP Address (you _don't_ need to enable the LAN Only Mode) - set SPOOLMAN_PROTO, _IP, _PORT - according to your SpoolMan installation - - Run the server + - Run the server (wsgi.py) - Run Spool Man - Add following extra Fields to your SpoolMan: - Filaments @@ -30,7 +30,8 @@ How to setup: - "nozzle_temperature","Nozzle Temperature","Integer Range","°C","190 – 230" - Spools - "tag","tag","Text" - - "active_tray","Active Tray","Text" + - "active_tray","Active Tray","Text + - Add your Manufacturers, Filaments and Spools to Spool Man (when adding filament you can try "Import from External" for faster workflow) - Open the server base url in browser on your mobile phone - Optionally add Bambu Lab RFIDs to extra tag on your Bambu Spools so they will be matching. You can get the tag id from logs or from browser in AMS info. - For non Bambu Lab filaments click on the filament and click Write and hold empty NFC tag to your phone (allow NFC in popup if prompted) diff --git a/config.py b/config.py new file mode 100644 index 0000000..beec9b9 --- /dev/null +++ b/config.py @@ -0,0 +1,8 @@ +import os + +BASE_URL = os.getenv('OPENSPOOLMAN_BASE_URL') # Where will this app be accessible +PRINTER_ID = os.getenv('PRINTER_ID') # Printer serial number - Run init_bambulab.py +PRINTER_CODE = os.getenv('PRINTER_ACCESS_CODE') # Printer access code - Run init_bambulab.py +PRINTER_IP = os.getenv('PRINTER_IP') # Printer local IP address - Check wireless on printer +SPOOLMAN_BASE_URL = os.getenv('SPOOLMAN_BASE_URL') +SPOOLMAN_API_URL = f"{SPOOLMAN_BASE_URL}/api/v1" diff --git a/config.template b/config.template deleted file mode 100644 index 39a3e02..0000000 --- a/config.template +++ /dev/null @@ -1,8 +0,0 @@ -BASE_URL = "" # Where will this app be accessible -PRINTER_ID = "" # Printer serial number - Run init_bambulab.py -PRINTER_CODE = "" # Printer access code - Run init_bambulab.py -PRINTER_IP = "" # Printer local IP address - Check wireless on printer -SPOOLMAN_PROTO = "" -SPOOLMAN_IP = "" # Spoolman IP address -SPOOLMAN_PORT = "" # Spoolman port -SPOOLMAN_API_URL = f"{SPOOLMAN_PROTO}://{SPOOLMAN_IP}:{SPOOLMAN_PORT}/api/v1" diff --git a/wsgi.py b/wsgi.py index d280c0f..0d257c7 100644 --- a/wsgi.py +++ b/wsgi.py @@ -2,4 +2,7 @@ from app import app import os if __name__ == '__main__': - app.run(debug=os.getenv('DEBUG', False), port=os.getenv('PORT', 443), host=os.getenv('HOST', '0.0.0.0'), ssl_context='adhoc') + if os.getenv('ADHOC_SSL', True): + app.run(debug=os.getenv('DEBUG', False), port=os.getenv('PORT', 8443), host=os.getenv('HOST', '0.0.0.0'), ssl_context='adhoc') + else: + app.run(debug=os.getenv('DEBUG', False), port=os.getenv('PORT', 8000), host=os.getenv('HOST', '0.0.0.0'))