Open eugeneyan opened 4 years ago
Hi Eugene, thanks a lot for this informative article!
From what I've read (e.g. this article), the advantages of FastAPI over Flask are speed, native async support and auto API documentation.
For building web apps, FastAPI's concise syntax and its documentation is certainly a plus, but Flask is well-proven, has a large community, number of available tutorials, Stack Overflow threads.
So, currently, I'd use FastAPI for building REST APIs and Flask for creating web apps (however I only have experience with the latter). Given your experience with FastAPI, which framework would you choose for which task?
Best wishes, Dominik
Comment by Dominik Haitz on 2020-07-27T14:12:54Z
Hey Dominik, thanks for sharing the comparison. Similarly, I've only had experience with Flask
but decided to build my new (web) app on FastAPI
.
So far, FastAPI has what I need (i.e., templates, jinja2, forms, serve); thus functionality is not an issue. The syntax is also simple and minimal. Nonetheless, as you mentioned, there are fewer tutorials and questions posted on SO (though it's growing daily).
My apps are mostly demos of machine learning prototypes and FastAPI meets my requirements (so far). Thus, I'll be switching fully to FastAPI for both REST and web. If I come across any blockers (i.e., missing functionality, bugs), I'll report them here.
Comment by Eugene Yan on 2020-07-27T14:50:42Z
great, thanks for your answer! :-)
Comment by Dominik Haitz on 2020-07-28T12:03:34Z
Just learning, but don't you need to have Jinja variable in the HTML for the result to show after POST? (
Result: {{result}}
). Might be totally missing something here. How does the result variable end up being presented in the HTML?I haven't come across the ellipsis operator before what does it do in Form(...) how would this be structured in older python?
FastAPI understands the ellipsis in Form(...)
to mean that the parameter is required. If the ellipsis isn't available, I think None can be used as well but it wouldn't enforce the argument requirement.
Other uses of ...
include array slicing and as a no-op placeholder.
Dear Sir,
I am trying to post html form data using fastapi using python.
Below is my public git repository.
https://github.com/bugindia2009/fapigithub
When I click on the submit button, I received an error Unprocessable Entity.
Please advise.
Migrated from json into utteranc.es