A Flask application factory creates an application object when the runtime loads it. The deployment entry point must call the correct factory with production configuration and expose the WSGI callable expected by the server.
IN THIS ARTICLE
Check access and requirements
Confirm the plan supports Python and a production WSGI integration. Identify the package path, factory name, virtual environment and required environment values.
01 Deploy a Flask application factory on WSGI hosting
Install the reviewed dependencies into the application virtual environment. Keep the project and private configuration outside the public static-file directory.
Create the WSGI entry point required by the hosting integration. Import the actual factory and create the application object, using the callable name expected by the panel or WSGI server.
Load production configuration before extensions or routes that depend on it are initialised. Avoid development-only database URLs and debug settings.
Start the app through the supported production WSGI server or panel control. Use the platform-supported process manager rather than an interactive development server.
Configure static files, HTTPS proxying and private error logs. Restart the application through the same supported control after deployment.
02 Example: expose a Flask factory as a WSGI callable
Suppose the project package is named customer_portal and exports a no-argument create_app factory. A hosting integration that expects a callable named application can use this small WSGI entry file in the private project directory.
from customer_portal import create_app
application = create_app()
Replace the package and factory signature with the actual project values. Configure the panel or WSGI server to load this file using the application’s virtual environment and production variables. The factory should load required settings before initialising database and other extensions. The two-line adapter does not configure a process supervisor by itself.
Expected result: A clean service restart loads the application without an interactive shell. Test both a simple page and a route using an extension; a successful import alone does not prove that the production database or mail configuration is correct.
Confirm the expected result
Request a public route, a route using a configured extension and a database-backed operation. Confirm the app restarts cleanly without the original SSH session.
Resolve setup problems
An import error often means the wrong working directory, missing package or incorrect virtual environment. A factory argument error needs the actual factory signature checked.
A common question
Can I use flask run for the public production site?
Use a production deployment integration. The development server and debugger are intended for development and do not replace a managed, production WSGI service.