[DOCKER] Notes and reference books when creating Web services with Flask

WIP

Introduction

Since I often write web servers using Flask, I will summarize the pages that I often refer to. I think it will be a collection of links for the time being, but if I have time, I would like to add more content. (It's about time to use FastAPI)

Main environment

Around Flask

session

Browser session

In Vanilla Flask with no plugins

server session You need to install a plugin. Backend options for saving sessions include Redis, other NoSQL, FileSystem, SQL, etc.

As a famous plug-in

and so on. FLask-Session accesses the backend that holds the Session from within Flask, but Beaker acts as middleware for the WSGI (eg Gunicorn) used. The latter also provides a Cache function. It has been confirmed that Flask-Session does not work properly when SQLAlchemy is specified as the backend (that is, SQL). (As of May 2020.5)

logging Flask and its plugins often provide a log output feature. To capture the output log with the Flask main unit log handle and output it

import logging
from flask.logging import default_handler #Log handler for flask body
#Other import etc.
from flask_cors import CORS

def create_app():
    # init_Various processing such as app
    #Here, the plugin you want to log`flask_cors`To
    cors_err_lggr = logger.getLogger('flask_cors')
    #Most plugins have the name of the built-in logger__name__Is it specified in?
    cors_err_lggr.setLever(logging.DEBUG)
    #Added default log handler
    cors_err_lggr.addHandler(default_handler)
    
    #Other processing

    return app

test

Around DB (MySQL, SQLAlchemy)

When setting independent columns (columns that are not Foreign Keys) in the intermediate table of many: many, it is better to use ʻassociation_proxy than to use relation`. Official Doc for association_proxy, with implementation example

Around Nginx, Gunicorn

Around Docker

Around deployment

Official Document It feels like Capistrano or Deployer Explanatory article 1 Explanatory article 2

in conclusion

No, FastAPI Isn't it good?

Recommended Posts

Notes and reference books when creating Web services with Flask
Launch a web server with Python and Flask
Easy machine learning with scikit-learn and flask ✕ Web app
Parse and visualize JSON (Web application ⑤ with Python + Flask)
Web application development with Flask
Web application with Python + Flask ② ③
Web application with Python + Flask ④
Easy deep learning web app with NNC and Python + Flask
Creating a web application using Flask ②
Creating a Flask server with Docker
Basic authentication and Digest authentication with Flask
Creating a simple app with flask
Creating a web application using Flask ①
Creating a web application using Flask ③
Creating a web application using Flask ④
Reputation of Python books and reference books
[GCP] Procedure for creating a web application with Cloud Functions (Python + Flask)
WEB scraping with Python (for personal notes)
[Python] Use and and or when creating variables
Getting Started with Flask with Azure Web Apps
Note when creating an environment with python
POST variously with Python and receive with Flask
Create a simple web app with flask
Easy web app with Python + Flask + Heroku
Create a web service with Docker + Flask
Practice web scraping with Python and Selenium
Easy web scraping with Python and Ruby
[ES Lab] I tried to develop a WEB application with Python and Flask ②
Try creating a web application with Vue.js and Django (Mac)-(1) Environment construction, application creation