Switch from the Flask server to another web server
Back to home
On this page
Note
The instructions on this page assume you’ve followed the Deploy Flask on Upsun guide. You may need to adjust the steps for your specific Flask implementation.
While lightweight and easy to use, Flask’s built-in server is not suitable for production as it doesn’t scale well. Upsun supports several different web servers for Python that you can use instead. Choose your server depending on your app and specific requirements.
The following instructions allow you to switch to Gunicorn. If you choose another web server, you may need to take different steps.
To switch to Gunicorn web server, follow these steps:
-
Open your
.upsun/config.yamlfile, and locate the section dedicated to the web server:.upsun/config.yamlweb: commands: start: "flask run -p $PORT" upstream: socket_family: tcpChange the
startcommand:.upsun/config.yamlweb: # Commands are run once after deployment to start the application process. commands: # The command to launch your app. If it terminates, it’s restarted immediately. # You can use the $PORT or the $SOCKET environment variable depending on the socket family of your upstream start: "gunicorn -w 4 'autoapp:app'" -
Commit your changes and push them to your environment. To do so, run the following commands:
Terminalgit add .upsun/config.yaml git commit -m "Changes project to use Gunicorn" upsun environment:push -y
Next steps
- Set up a more robust local development environment
- Add a source control integration
- Add various services to your project