Comments (17)
@deb17 There are extensions such as fastapi-sqlalchemy. But it's still new and not as feature rich as flask-sqlachemy.
from blog-comments.
Very clear and concise intro to FastAPI for Flask users! FastAPI has some great documentation but I'd love if you included an example of the FastAPI documentation generation. Then you could show how to use the example key of schema_extra in class Config as well as tags to customize the generated documentation. It would fit very nicely with how you have introduced FastAPI's implementation of Pydantic schema. I really enjoyed using these features recently if you want some examples.
That would make this an even more perfect intro to FastAPI for friends and colleagues who use Flask!
from blog-comments.
@cjakuc That sounds like a good idea. I'll add sections on those to the post.
If you've some interesting examples to share from your experience, I would love to hear them.
from blog-comments.
I like the updates to the post! I had no idea about /redoc. I've only used FastAPI once now but really loved it and there's obviously still so much for me to learn, I'll share my example below.
Here is the deployed API with customized schema_extra and tags.
Here is a .py file in the GitHub repo that shows the definition of a customized schema_extra.
The list of tags/descriptions are created in main.py, passed into the app when it is instantiated (also in main.py), and called when creating the corresponding endpoints within the routers folder.
My work could definitely use some refactoring to better utilize the Pydantic BaseModel like you did in your nested objects example. That would make the schema_extra tweaks a little redundant but you could still do this to show an example when defining the UserGroup class:
class UserGroup(BaseModel):
users: List[User]
group: str
class Config:
schema_extra = {
"example": {
"users": [
{
"name": "xyz",
"age": 25
},
{
"name": "abc",
"age": 30
}
],
"group": "Group A"
}
}
from blog-comments.
Check out instant_api, for a FastAPI-like experience but within Flask.
from blog-comments.
@alexmojaki Looks interesting. Thanks for sharing your project.
from blog-comments.
I like fastAPI. I use it in one of my projects
FastAPI is good if you need just backend like API or something
I use it in my chatbot project that has no frontend part
but in another project I still prefer to use Flask
because if I make a web app I have to cope with logins or jwt, webforms, databases (orm) and some sort of admin panels
from blog-comments.
@IDQDD Agree with you. It's important to choose the right tool for the right job. If a project has frontend templating needs, Flask/Django is a more suitable choice.
from blog-comments.
Hi! It's really nice introduction to FastApi. In general FastApi looks like a good alternative for Flask. I wonder I you came across any limitations, shortcomings when working on production with FastApi?
from blog-comments.
@kstrz For my usecase there were no limitations since my project involves only REST APIs and I was on "Python 3.7".
If your project involves a lot of jinja templating and server-side rendering of HTML templates, then FastAPI is not a good choice.
Also, FastAPI only supports python 3.6+, so if your project is written in older version of Python or has some legacy dependency, you might have to rewrite few portions. Making sure all dependencies work could be a trouble.
from blog-comments.
Another similar library: https://github.com/zero-shubham/flask-ease
from blog-comments.
Thank you for your overview about fastAPI
from blog-comments.
Nice introduction to fastapi. I am thinking of using it as the backend for my vuejs projects. But what about database access? Does it have extensions like flask-sqlalchemy and flask-migrate? Or do we have to fall back on sqlalchemy and alembic?
from blog-comments.
Great article, Amit!
Did you have any experience with streaming responses? In Flask, this is achieved by having your route method returning a generator that will be yielding response chunks. This is useful when the response data is being generated on the fly and large in size (e.g., my Flask REST API is building a video or audio clip and sending to client who asked to download it).
Thanks!
from blog-comments.
@quantotto Look into: https://fastapi.tiangolo.com/advanced/custom-response/#streamingresponse
from blog-comments.
Great post and very helpful to have the side by side examplse.
My understanding is that you need to defined all the FastApi function as "async" to really get performance benefits compared to Flask. If the functions are run on the main thread, then there is not really any peformance benefits.
from blog-comments.
thx! Very usefull
from blog-comments.
Related Issues (20)
- 2020/06/google-colaboratory-tips/ HOT 6
- 2020/03/illustrated-simclr/ HOT 32
- 2020/08/information-retrieval-evaluation/ HOT 6
- 2020/06/fasttext-embeddings/ HOT 8
- vscode-on-colab/ HOT 25
- 2020/02/tensorflow-hub-for-transfer-learning/
- 2020/02/albert-visual-summary/ HOT 3
- keyphrase-extraction/ HOT 1
- knowledge-transfer/ HOT 7
- 2020/03/fixmatch-semi-supervised/ HOT 5
- interactive-sentence-embeddings/ HOT 2
- 2019/12/migrating-to-pathlib/ HOT 3
- 2020/07/semi-supervised-learning/ HOT 6
- 2020/04/deepcluster/ HOT 7
- regex/ HOT 6
- 2020/03/illustrated-pirl/ HOT 1
- 2018/10/django-orm-for-sql-users/ HOT 2
- 2020/04/illustrated-self-labelling/ HOT 4
- 2019/03/automate-ssh-commands/ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog-comments.