Configuration
Environment variables, config files, feature flags
This page explains how to configure the plant-disease-predictor application so it runs correctly in your environment. Configuration is split across two files — config.toml and credentials.toml — which control server behavior, logging, browser connectivity, and account credentials. Getting these settings right before you launch ensures the app is reachable, performs well, and behaves predictably when you upload leaf images for disease analysis.
Before adjusting any configuration, make sure you have the following in place:
- Python 3.8 or later installed on your system
- pip (Python package manager) available in your terminal
- The following Python packages at the exact versions used by this project:
numpy==1.26.3streamlit==1.30.0tensorflow==2.15.0.post1
- Write access to the project directory so you can edit
config.tomlandcredentials.toml - A terminal or command prompt open at the project root
Follow these steps to install all dependencies and place the configuration files correctly.
-
Clone or download the project to your local machine and navigate into the project directory:
cd plant-disease-predictor -
Install the required Python packages using the provided
requirements.txt:pip install -r requirements.txtThis installs
numpy,streamlit, andtensorflowat the exact versions the application was tested with. Installing different versions may cause unexpected behavior. -
Verify the configuration files exist in the project root. You should see both:
config.toml credentials.tomlIf either file is missing, create it manually using the examples in the Configuration section below.
-
Confirm Streamlit is available by running:
streamlit --versionExpected output:
Streamlit, version 1.30.0
Once installation is complete, you are ready to adjust configuration values before launching.
All configuration lives in two TOML files at the project root. Edit these files with any text editor before starting the application.
config.toml
This file controls Streamlit's runtime, server, logging, and browser behavior.
[global]
| Key | Default | Valid values | Effect |
|---|---|---|---|
showWarningOnDirectExecution | true | true, false | When true, Streamlit prints a warning if you run the script with python instead of streamlit run. Keep this enabled during development to avoid confusion. |
[logger]
| Key | Default | Valid values | Effect |
|---|---|---|---|
level | "info" | "error", "warning", "info", "debug" | Controls the verbosity of log output. The current setting is "debug", which prints detailed messages useful for diagnosing prediction or connectivity issues. Switch to "info" or "warning" in production to reduce noise. |
[runner]
| Key | Default | Valid values | Effect |
|---|---|---|---|
magicEnabled | true | true, false | Allows bare Python expressions on a single line to be rendered in the app. Disabling this is rarely necessary unless you encounter unexpected output in the UI. |
[server]
These settings control how the application server listens for and handles connections.
| Key | Default | Valid values | Effect |
|---|---|---|---|
folderWatchBlacklist | [] | List of paths | Folders the server will not watch for file changes. Useful for excluding large virtual-environment directories from hot-reload scanning. |
headless | false (platform-dependent) | true, false | Set to true to prevent the server from opening a browser window automatically on startup. Required when running on a remote server or inside a container. |
liveSave | false | true, false | When true, the app is immediately shared for live monitoring. Leave as false for standard local or self-hosted use. |
runOnSave | false | true, false | When true, the app automatically reruns whenever the script file changes on disk. Convenient during development; keep false in production. |
port | 8501 | Any valid port integer | The port the server listens on. The current value is 80 (standard HTTP), which means you can access the app without specifying a port in your browser URL. Ensure this port is open in your firewall or security group. |
enableCORS | true | true, false | Enables Cross-Origin Resource Sharing protection. Currently set to false — re-enable this (true) in any internet-facing deployment to prevent unauthorized cross-origin requests. |
[browser]
These settings tell the browser-side client where to connect.
| Key | Default | Valid values | Effect |
|---|---|---|---|
serverAddress | "localhost" | IP address or DNS name | The address the browser uses to reach the server. "0.0.0.0" means the server accepts connections on all network interfaces, making it reachable from other machines on the network. |
gatherUsageStats | true | true, false | When true, anonymous usage data is sent to Streamlit. Set to false if your deployment environment does not permit outbound telemetry. |
serverPort | Same as server.port | Any valid port integer | The port the browser connects to. This must match server.port (both are set to 80 here). |
credentials.toml
This file stores optional account credentials used by Streamlit's sharing features.
[general]
| Key | Default | Effect |
|---|---|---|
email | "" | Your Streamlit account email. Required only if you use Streamlit Cloud sharing or liveSave. Leave blank for self-hosted deployments. |
Once your configuration files are in place and dependencies are installed, you launch the application with a single command.
Starting the application:
streamlit run app.py --config config.toml
Because server.headless is set to true, no browser window opens automatically. Open your browser manually and navigate to:
http://localhost:80
or, if you are accessing from another machine on the network:
http://<your-server-ip>:80
During development, you may want to enable runOnSave so the app reloads whenever you modify the script:
[server]
runOnSave = true
In production, keep runOnSave = false and switch the log level to reduce output:
[logger]
level = "warning"
Restricting external access: If you only need local access, change serverAddress to "localhost" in [browser] and ensure server.port is set to a port not exposed publicly.
Tip: Always restart the application after editing
config.tomlfor changes to take effect.
The examples below show common configuration scenarios you might encounter when deploying the plant-disease-predictor.
Example 1 — Local development setup (verbose logging, auto-reload)
Use this configuration when you are developing locally and want maximum feedback:
[logger]
level = "debug"
[server]
headless = false
runOnSave = true
port = 8501
enableCORS = true
[browser]
serverAddress = "localhost"
serverPort = 8501
Launch with:
streamlit run app.py
Expected behavior: Streamlit opens a browser tab at http://localhost:8501 automatically. Every time you save app.py, the app reruns. Debug messages appear in your terminal.
Example 2 — Production server deployment (headless, restricted logging)
Use this configuration when hosting on a remote server or VM:
[logger]
level = "warning"
[server]
headless = true
runOnSave = false
port = 80
enableCORS = true
[browser]
serverAddress = "0.0.0.0"
serverPort = 80
Launch with:
streamlit run app.py
Expected behavior: No browser opens on the server. The app is reachable at http://<your-server-ip> from any machine. Only warnings and errors appear in logs.
Example 3 — Disabling usage statistics
If your environment blocks outbound telemetry, add this to config.toml:
[browser]
gatherUsageStats = false
Expected behavior: No usage data is sent to Streamlit's servers. All other functionality remains unchanged.
Use the table below to diagnose and fix the most common configuration-related problems.
Problem: The app fails to start because port 80 is already in use
- Symptom: Terminal shows
OSError: [Errno 98] Address already in useor similar. - Likely cause: Another process (e.g., a web server like Apache or Nginx) is already listening on port 80.
- Fix: Either stop the conflicting process, or change
server.portandbrowser.serverPortinconfig.tomlto an available port such as8501, then restart.
Problem: Navigating to localhost:80 shows a blank page or connection refused
- Symptom: Browser cannot load the app after running
streamlit run app.py. - Likely cause:
server.headlessisfalseand the app tried to open a browser before fully initializing, orbrowser.serverAddressis set to"0.0.0.0"but you are connecting vialocalhost. - Fix: Confirm the terminal shows
You can now view your Streamlit app in your browser. IfserverAddressis"0.0.0.0", try navigating tohttp://127.0.0.1:80instead.
Problem: Changes to config.toml have no effect
- Symptom: After editing a setting, the app still behaves as before.
- Likely cause: The application was not restarted after saving the file.
- Fix: Stop the running process (
Ctrl+C) and relaunch withstreamlit run app.py. Configuration is only read at startup.
Problem: Excessive log output is cluttering the terminal
- Symptom: The terminal is flooded with
DEBUGmessages during normal operation. - Likely cause:
logger.levelis set to"debug"inconfig.toml. - Fix: Change the level to
"info"or"warning"for less verbose output, then restart the app.
Problem: The app is accessible from unintended external machines
- Symptom: Users outside your network can reach the app, or security scans flag an open port.
- Likely cause:
browser.serverAddressis"0.0.0.0"andenableCORSisfalse, leaving the server open without cross-origin protection. - Fix: Set
enableCORS = truein[server]immediately. If you only need local access, also changebrowser.serverAddressto"localhost"and restrict port 80 at your firewall level.
Problem: tensorflow or numpy import errors on startup
- Symptom: Streamlit launches but shows an
ImportErrororModuleNotFoundErrorin the browser or terminal. - Likely cause: Dependencies were not installed, or were installed at incompatible versions.
- Fix: Run
pip install -r requirements.txtagain in the same Python environment you use to launch the app. Verify versions withpip show tensorflow numpy streamlit.