Sites and apps
How to put a Flask app online
In short
To put a Flask app online, list Flask and gunicorn in requirements.txt, take the port from the PORT variable, and upload the code to a platform that builds it for you. The built-in Flask server is not meant for the internet, so gunicorn runs the app. Netrun detects Python, builds the project and gives you an HTTPS link, passing the secret key and tokens in from secrets as environment variables.
- The built-in Flask development server is not meant for the internet, so a published app runs on gunicorn.
- A Flask app should take its port from the PORT environment variable, for example int(os.environ.get("PORT", 5000)), instead of a hardcoded number.
- A Flask app has to listen on 0.0.0.0: on 127.0.0.1 it is reachable only from inside the server.
- Netrun stores the Flask secret key and the database connection string encrypted and passes them to the app as environment variables.
- There is no need to upload the venv folder: Netrun installs the dependencies from requirements.txt itself.
Normally, to expose a Flask app to the outside world, you have to rent a server, install Python on it, configure gunicorn and nginx, issue an SSL certificate, and keep an eye on the process so it does not crash. For a pet project or your first Flask site, that is a lot of fuss before anyone even sees the result.
Netrun takes that part away: you upload your code, the platform figures out on its own that it is Python with Flask, builds the project, and gives you a public HTTPS link. We handle the servers, the build, and restarts. Below is how to prepare your app and get it online in a few minutes.
List your dependencies in requirements.txt#
Put a requirements.txt file next to your code with the list of libraries — at least Flask and gunicorn. Gunicorn is the production server that keeps your app running under load, since the built-in Flask server is not meant for the internet. You do not need to include the dependencies folder (venv) in the archive — Netrun installs everything itself from the list.
Listen on the port from an environment variable#
Do not hardcode port 5000 in your code. Netrun assigns the app the right port through the PORT environment variable, and the app should read it — for example, port = int(os.environ.get("PORT", 5000)) — taking the value from that variable. Gunicorn also binds to this port when it starts. If the port is hardcoded, the link may not open.
Keep keys and tokens out of your code#
Do not leave the Flask secret key, keys to external services, or the database connection string right in your files. Read them from environment variables via os.environ — Netrun asks for these values during setup and passes them into the app, so they are not stored in the code.
Upload the project to Netrun#
Open your dashboard and upload the code: as a ZIP archive or by importing from a GitHub repository, including a private one. The platform detects on its own that it is Python with Flask and prepares the build — you do not need to specify the language separately.
Enter the secrets and publish#
On the setup step, fill in the values the app expects from the environment — the secret key, tokens, the database connection string. Then start the deploy. The build progress and logs show in the dashboard in real time, so you can see exactly which step everything is at.
Check it at the link#
Once the build reaches the ready status, open the link you were given — the app is already running over HTTPS. If something goes wrong, check the logs in the dashboard, and on a failure Netrun restarts the project automatically.
That is it: your Flask app lives online without renting a server, setting up nginx by hand, or fiddling with certificates. On the Free plan, one web project sleeps when idle and wakes on the first request — after a pause it opens a little slower. If the app needs to respond instantly and stay online all the time, a paid plan with no idle sleep is a good fit. Try Netrun.
Common questions
Why can't I just run app.run() on the server?
The built-in Flask server is made for development, and Flask itself warns on startup that it is not suitable for a production site. Gunicorn runs several worker processes and handles requests more reliably. Locally, app.run() is still handy.
What does the gunicorn start command for Flask look like?
Usually like this: gunicorn app:app --bind 0.0.0.0:$PORT. The first app is the file name without .py, the second is the variable that holds your Flask app; if the file is main.py, the command becomes gunicorn main:app.
Where should a Flask app store uploaded files?
In the persistent /data folder: whatever the app writes there survives code updates and restarts. Files outside /data disappear on the next publish. You can view, download or delete them in the Data tab of your dashboard.
What if the link does not open after publishing?
Open the logs in your dashboard — the reason usually shows up there. Most often the app listens on 127.0.0.1 instead of 0.0.0.0, the port is a hardcoded number instead of the PORT variable, or a library is missing from requirements.txt.
Can I host a Flask site for free?
Yes, the Free plan includes one project: the site sleeps without visitors and wakes on its own when someone opens it, with the first load after sleep taking a few seconds. To keep the site from sleeping, you need the Pro plan.