Use env variables

Fix readme
Change default port
This commit is contained in:
Filip Bednárik 2024-12-13 09:58:45 +01:00
parent ff9c508e3c
commit a56c78b24a
5 changed files with 17 additions and 15 deletions

2
.gitignore vendored
View File

@ -130,5 +130,3 @@ cython_debug/
# IDE files # IDE files
.idea/ .idea/
config.py

View File

@ -1,11 +1,11 @@
# OpenSpoolMan # OpenSpoolMan
Use any filament like Bambu filaments with automatic recognition and filament usage updates in your AMS! 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 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: What you need:
- Android Phone with Chrome web browser or iPhone (manual process much more complicated) - 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_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 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 - set SPOOLMAN_PROTO, _IP, _PORT - according to your SpoolMan installation
- Run the server - Run the server (wsgi.py)
- Run Spool Man - Run Spool Man
- Add following extra Fields to your SpoolMan: - Add following extra Fields to your SpoolMan:
- Filaments - Filaments
@ -30,7 +30,8 @@ How to setup:
- "nozzle_temperature","Nozzle Temperature","Integer Range","°C","190 230" - "nozzle_temperature","Nozzle Temperature","Integer Range","°C","190 230"
- Spools - Spools
- "tag","tag","Text" - "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 - 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. - 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) - 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)

8
config.py Normal file
View File

@ -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"

View File

@ -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"

View File

@ -2,4 +2,7 @@ from app import app
import os import os
if __name__ == '__main__': 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'))