Your directory structure should look similar to the one below. Inside app, create two packages main and test. In the project directory, create a new package called app. In a functional structure, templates are grouped together in one directory, static files in another and views in a third. I will be using a functional structure to organize the files of the project by what they do. ![]() Set up virtual environment and virtual environment wrapper (you only need one of these, depending on the version installed above): sudo pip install virtualenvįollow this link for a complete setup of virtual environment wrapper.Ĭreate a new environment and activate it by executing the following command on the terminal: mkproject name_of_your_project Project Setup and Organization ![]() Choose either the Python 2.x OR 3.x version. If the terminal responds with the version number, this means that pip is installed, so go to the next step, otherwise install pip or using the Linux package manager, run the command below on the terminal and press enter. Setup and InstallationĬheck if you have pip installed, by typing the command pip -version into the Terminal, then press Enter. It provides a coherent collection of decorators and tools to describe your API and expose its documentation properly (using Swagger). Flask-RESTPlus encourages best practices with minimal setup. Flask-Script: An extension that provides support for writing external scripts in Flask and other command-line tasks that belong outside the web application itself.įlask-RESTPlus is an extension for Flask that adds support for quickly building REST APIs.JWT is an open, industry-standard ( RFC 7519) for representing claims securely between two parties. PyJWT: A Python library which allows you to encode and decode JSON Web Tokens (JWT).Flask-SQLAlchemy: An extension for Flask that adds support for SQLAlchemy to your application.The database operations are made available through the Flask command-line interface or through the Flask-Script extension. ![]() Flask-Migrate: An extension that handles SQLAlchemy database migrations for Flask applications using Alembic.Flask-Bcrypt: A Flask extension that provides bcrypt hashing utilities for your application.We’ll be using the following features and extensions within our project. This guide is divided into the following parts: If you are not familiar with those, I recommend taking a look at an introductory article - How to use Python and Flask to build a web app. I will be using a Linux based OS (Ubuntu), but most of the steps can be replicated on Windows and Mac.īefore continuing with this guide, you should have a basic understanding of the Python programming language and the Flask micro framework. In this guide I’ll show you a step by step approach for structuring a Flask RESTPlus web application for testing, development and production environments. By Greg Obinna How to structure a Flask-RESTPlus web service for production builds Image credit - .uk
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |