Remote: Total 79 (delta 26), reused 66 (delta 16), pack-reused 0įrom the local machine, secure copy (SCP) the project into the /home directory of the Linode. Remote: Compressing objects: 100% (57/57), done. If you are not using the example repository, Example Flask Blog Application, replace the example repo with the name of the repo that you want to use: git clone git clone Replace the example IP address with the IP address of the Linode: ssh to the home directory of Linode: cd ~Ĭlone the project from the remote version control system. Clone the App From Source ControlĮnsure that the latest Flask application code is available in the project’s remote repository. If you prefer, you can store the application files in a different directory, however, ensure you run the examples in the directory of the application. This guide’s examples transfer the Flask application files to the Linode’s /home directory. This section provides steps for both options. You can accomplish this by either cloning the GitHub project to the Linode using Git or by using the secure copy method to directly transfer the application files to the Linode. You need to copy the local Flask application code to the Linode. You may also wish to set the timezone, configure your hostname, create a limited user account, and harden SSH access.Īfter creating the Flask application in the local development environment, you are now ready to deploy it to a production environment. ![]() See our Getting Started with Linode and Creating a Compute Instance guides.įollow our Setting Up and Securing a Compute Instance guide to update your system. If you have not already done so, create a Linode account and Compute Instance. If you are not using the example application, host the Flask application code on a remote version control system, such as GitHub. The root directory of the application is flask_app_project. The Example Flask Blog Application is used throughout this guide. In this guide you complete the following:Ĭopy an existing Flask application from a local development environment to a production environmentĬonfigure the Flask application’s production environment variables This guide does not cover creating a Flask application or related Python concepts. The production environment uses NGINX as the web server and reverse proxy, Gunicorn as the web server gateway interface (WSGI) application server, and Supervisor for monitoring and auto-reloading Gunicorn should it go down. ![]() This guide walks you through the steps to deploy a Flask application to a production environment running on a Linode. After you have developed a Flask application in a local environment, you need to prepare the application’s production environment in order to run the application and serve it to the users of the application through the internet. The first thing we do in the API is create the Flask app and import the games controller.Flask is a light-weight web framework for Python that includes several utilities and libraries you can use to create a web application. ![]() Now that we have the CRUD of the operations with the database, it is time to expose everything in the API with Flask. Note that all functions use the database and a cursor to perform all operations. We also see other methods such as update_game that performs the UPDATE operation to update a game, delete_game that deletes a game ( DELETE) from its id, get_by_id that returns a game from its id (using the SELECT operation).įinally we look at the get_games function that returns all existing games. The insert_game function receives the game data and inserts it into the database ( INSERT) all this using prepared statements to avoid SQL injections in this API that we are creating with Python and Flask.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |