Impressions of using Flask for a month

I got the impression that it was good to know Flask on pyconjp etc. in 2012 and it was a micro framework and could be used to make a small service. After a while, there was talk of creating a REST API using RDB, but I will write my impressions that I had a hard time and failed using Flask.

  1. Easy to use MethodView class Creating a REST API was really easy because if you create a class that inherits the MethodView class for each entry point and define the get / post / put / delete method, you can handle GET / POST / PUT / DELETE requests respectively.

  2. Do not use POST to update resources For API users, I made the specification to accept updates by POST, but when I started implementing it, I thought it would be troublesome. This method wasn't very suitable for using SQLAlchemy as an ORM. If you create the REAST API with POST / PUT / DELETE / GET, both developers and users will be happy.

  3. Flask-SQLAlchemy is hard to use. Flask-SQLAlchemy is also difficult to use beyond the sample because there are no examples of use that can be used as a reference. It's more flexible to use plain SQLAlchemy, and the code can be used for other batch processing, so I think it's better not to use extensions as much as possible.

  4. Not many Blueprint documentation When the code grows after a while, I feel that one script is too big and I want to use a module called Blueprint that divides the code, but this also has no documentation and I can use it by reading the code It takes time and effort to get it done. I gave up the division using Blueprint and forced it into one file.

  5. It is difficult to understand how to test Regarding 3,4,5, I think it results in the lack of documentation / sample code in general. Flask has few usage examples, so I hope that the amount of information in this section will increase in the future.

  6. Cannot receive parameters in DELETE request I didn't notice it until I started implementing it, so please be aware that if you adopt a specification that changes resources at the timing of deletion, you will be in trouble later. Addition Properly, I got the parameters with request.args ["hoge"] in the DELETE request as below. % curl -X DELETE "http://localhost:9999/users/100?hoge=100"

As for SQLAlchemy, I tried using it with the knowledge that I had used it for a while, so it may have been off the mark. I wrote it because I might be addicted to making something with Flask + SQLAlchemy as a beginner.

I had a lot of experience with Flask in 2012, so in 2013 I'll try to add new experiences with Django, which has more features than Flask.

I look forward to working with you again this year.


Amazon.co.jp: Technology that supports the Web-HTTP, URI, HTML, and REST (WEB + DB PRESS plus): Yohei Yamamoto: Book

PyCon JP 2012 hands-on session / Web application implementation and programming tools with Flask

Recommended Posts

Impressions of using Flask for a month
A memorandum of using eigen3
Avoiding the pitfalls of using a Mac (for Linux users?)
Creating a web application using Flask ①
Creating a web application using Flask ③
Creating a web application using Flask ④
Getting a combination of elements using itertools
What Java users thought of using the Go language for a day
[Python] Split a large Flask file using Blueprint
Find the number of days in a month
A proposal for versioning of features in Kedro
A memorandum for touching python Flask on heroku
Tips for using ElasticSearch in a good way
Let's make a module for Python using SWIG
A memorandum of method often used in machine learning using scikit-learn (for beginners)
[Python] Implementation of clustering using a mixed Gaussian model
Create a dataset of images to use for learning
Released a web service for scoring handwriting using DeepLearning
Cut a part of the string using a Python slice
A memo of installing Chainer 1.5 for GPU on Windows
A brief summary of Linux antivirus software for individuals
I built a Wheel for Windows using Github Actions
[Python] I tried running a local server using flask
Python: Get a list of methods for an object
Read a large amount of securities reports using COTOHA
Implementation of a convolutional neural network using only Numpy
I tried using Python (3) instead of a scientific calculator
Memo for building a machine learning environment using Python
(For myself) Flask_2 (list and for, extends, and a little more)
Impressions of touching Django
Example of using lambda
The story of creating a VIP channel for in-house chatwork
Implementation of VGG16 using Keras created without using a trained model
Let's create a function for parametrized test using frame object
Recommendation of Jupyter Notebook, a coding environment for data scientists
A memorandum of stumbling on my personal HEROKU & Python (Flask)
Search for stable structures of metal nanoclusters using genetic algorithms
Reuse the behavior of the @property method by using a descriptor [16/100]
I wrote a demo program for linear transformation of a matrix
Try a similar search for Image Search using the Python SDK [Search]
I tried using Tensorboard, a visualization tool for machine learning
(For myself) Flask_4 (Drop-down menu, view txt data (using table))
Scrapy-Redis is recommended for crawling a large number of domains
[Django] A collection of scripts that are convenient for development
A memo of writing a basic function in Python using recursion
Incorrect answer when using numpy.prod () for B problem of ABC169
Build a Flask development environment at low cost using Docker
[For beginners] A word summary of popular programming languages (2018 version)
Turn an array of strings with a for statement (Python3)
The story of creating a database using the Google Analytics API
Construction of Cortex-M development environment for TOPPERS using Raspberry Pi
Try using [Tails], a purveyor of hackers (?), By USB booting.
[End of 2020] A memo to start using AWS CLI (Version 2)