Flask

Flask

Application and Data / Languages & Frameworks / Microframeworks (Backend)
Needs advice
on
FlaskFlask
and
ReactReact

Hello all! I am new here. For one of my personal projects, I am trying to build an app around an ML model. I have created an API for the ML model using Flask. How do I proceed from here? It is a model that classifies the emotion into one of 7 categories, based on the textual input given by the user. Then, from a database of songs that are tagged with the appropriate emotion they convey, three random songs are selected and the links are provided to the user. I want to build an app around this. I also want to be able to get feedback from the user and incorporate it into the ML model to train it further. I am capable of using React for the frontend part.

READ MORE
6 upvotes·75.3K views
Replies (1)
Systems Engineer at Infosys·
Recommends
on
React

I don't think this is a fair comparison as both are different ends. Flash is a microframework of Python, and React is a UI library of Javascript. Try building the app using React, as it has a rich ecosystem around visualizations. Just a quick thing to say, if you want to develop a good application you have to use Javascript in any way.

READ MORE
4 upvotes·10.2K views
Needs advice
on
DjangoDjango
and
FlaskFlask

I'd like to make a web app using Python as a primary language and PostgreSQL for data management. Using those two I can do all the back-end and control functionality, but presenting it as a webpage is still a slight challenge.

I could do everything with pure HTML5, but I would like to try a framework to speed up the process and make it more maintainable. Django and Flask seem the two most popular frameworks for Python web development, but I'd like to hear your opinions on the matter (I'm also up to trying any other Python-based framework that is an 'industry standard if there is such a thing).

I intend to do styling myself, and being able to create dynamic and responsive websites is a must-have.

Bonus points for tips on what web server environment to use. (I've done Apache2 in the past but I think it may be outdated)

READ MORE
7 upvotes·87K views
Replies (3)
Recommends
on
Django
Flask

Hi flashing-blinkenlights,

Python has an excellent ecosystem with a number of mature server-side web frameworks, a wide variety of libraries, and a lot of learning resources to boot.

Flask and Django are both great frameworks for producing web applications, but they have different strengths. Judging from your description of your project, you need a Python-based server-side web framework with an easy-to-use ORM, and for that reason, I would recommend that you look into Django as it's a "batteries-included" kind of framework. Also, it has a great admin tool built-in that makes it very easy to produce a UI for managing the database entities you create directly from within the browser.

In case you, at some time, would like to evolve your platform to be REST API-driven to some degree (e.g., for consumption by external parties), Django also has the "Django Rest Framework" plug-in, which provides all the tooling and documentation needed to produce well-behaving and secure REST APIs.

As for the choice of webserver running in a reverse proxy configuration, you can use Apache HTTPD for sure. Very popular these days is a rival webserver called "Nginx," which performs well and with a lot of momentum.

For quickly and easily getting a Django app running in production, I can recommend considering Heroku, at least in the beginning. It offers a path of very low resistance, and you don't need to worry about the reverse proxy config either.

I hope this helps, and good luck with your project. 🙂

Best, Thomas

READ MORE
5 upvotes·4K views
Co-founder at Trinesis·

That "industry standard if there is such a thing" gave me a chuckle.

Try keeping backend and frontend independent of each other, saves a lot of efforts (read time debugging).

Use your backend via APIs, they are the best, can be used with any other service. You can call your APIs through web-app, mobile-app, or any other app or you can sell your data through these APIs. Now to build APIs, you can use Django REST, or Flask, or FastAPI (very fast :)) or any other web framework. I would suggest go for Django REST, but up to you, if you are a kind of person who wants to build everything from ground up, having full control, wants to know what goes in and what comes out, don't go for Django, as they say, Django is "batteries included", gives a lot of functionalities out of the box. For eg: If you want to write some filters, or ordering, or pagination, or permissions, in your APIs, in Django REST you won't to have to write any code for that, but in flask/FastAPI, you will have to, just to give you an idea.

For frontend, use react, it's supper good, large community, you will get a lot of help.

For web-server, you can go for Apache or nginx, Apache is not outdated, it's very widely used. I would prefer nginx, but it's a personal choice. In either case, you will have to use WSGI, for Python, as it's not natively supported by either web servers, you will use both of them as reverse proxy. It will be like:

apache/nginx <--> some wsgi <--> your python web server

That's backend.

Frontend will be like: Compile ReactJS project --> generate static files --> server those static files via Apache/nginx.

Hope that helps.

READ MORE
5 upvotes·4.1K views
View all (3)
Needs advice
on
FlaskFlask
and
Spring BootSpring Boot

I have to use one of these two frameworks for a test in one week. I have an extremely small amount of exposure to Spring Boot and no exposure to Flask. Which should I learn?

READ MORE
2 upvotes·84.2K views
The Community Management ·
Needs advice
on
Django REST frameworkDjango REST framework
and
FlaskFlask

Hey! So I am planning to make an e-commerce website with React Native as my frontend technology stack and MongoDB as my database. I was wondering what will be the best REST framework to use for my backend that will simply serve the frontend. Is Django rest framework a good option or should I go with Flask? I am currently leaning towards flask as the development team is well versed in it. Please help!

READ MORE
3 upvotes·145.9K views
Replies (2)
Software Consultant at CODIUM·

If the application is simple such as less endpoint or simple logic, I'd suggest Flask. But what you're building is quite a large system that contains many logics and a lot of models. So I'd suggest you with Django and Django REST framework. Django ORM is also one of the best ORM in the world as well.

READ MORE
2 upvotes·65.1K views
Software Engineer at hyphenOs·
Recommends
on
FastAPI
fastapi

FastAPI is modern microframework. If you haven't used any of them, I'd suggest FastAPI. Django REST is also good if you have previous experience with it.

READ MORE
2 upvotes·68.6K views
Software Engineer ·
Needs advice
on
FlaskFlaskconnexionconnexion
and
QuartQuart

I'm considering moving from Flask to Quart, does anyone have some experience with this migration?

I expect possible problems with connexion which we use as OpenAPI specification.

Would be good if someone can point downsides of moving to the Quart framework so I can double-check if my plan is worth doing.

Other libs and tools used in the project: SQLAlchemy, alembic, PostgreSQL, Datadog

cons for now:

  • Refactoring uncertainty (not sure how big of a task is it)
  • Connexion might not work with Quart (moving to another library)
  • ...
READ MORE
8 upvotes·111.9K views
Senior Systems Engineer at Infosys·
Needs advice
on
GunicornGunicornwaitresswaitress
and
uWSGIuWSGI

I want to choose one of the WSGI servers to be used along with Flask. Later on, I will be dockerizing the app. Which one would be the best one out of these?

READ MORE
2 upvotes·74.8K views
Replies (1)

Lately, with all that AI buzz, langchain and all, I had to do a lot of Python work, where each service runs as a REST API end-point. Obviously, I wanted to go the “dynamic routing” way, as I did on Foxx Builder (https://github.com/skitsanos/foxx-builder) and other projects, so I needed Flask to handle my route handlers exactly the same way. I went with Gunicorn initially; you can even see it here: https://github.com/skitsanos/flask-dynamic-routes. But it all was fine until its multithreading backfired when I wanted to run it in containers. Azure libs that I used didn't like how it worked, and I needed a bunch of containers behind the load balancer. I had to migrate to Waitress, and my headaches were gone.

Waitress is single-threaded, which means it serves requests in a sequential manner, one after another. This makes it easy to reason about how your application handles concurrent requests.

Gunicorn, on the other hand, uses multiple worker processes (usually multiple threads within each process) to handle concurrent requests. While this can improve concurrency and performance, it can also introduce synchronization and thread safety complexities in your application code.

Waitress is designed to be a simple, production-ready WSGI (Web Server Gateway Interface) server that's easy to set up and use. It's a pure-Python server that doesn't require any additional configuration or management.

Gunicorn, while powerful and feature-rich, can be more complex to set up and configure, especially if you need to manage multiple worker processes. In my case, I didn’t need all that fancy stuff. Gunicorn sounded to me like a swiss-knife, when, in my case, I just needed a simple butter knife.

Waitress is a lightweight server with minimal overhead. It doesn't have as many features as Gunicorn, but it's often sufficient for smaller applications and can be a better choice when you want to keep your server footprint minimal.

Gunicorn is a more heavyweight server with more features and options. This can be advantageous for larger applications with high traffic, but it may be overkill for simpler projects.

Some of my things are offloaded to OpenResty directly, so Lua handles things even before it reaches the Python backend. My main criteria here were to have super-fast deployment, super simple configuration when running in a container, and the ability to handle a big load.

READ MORE
skitsanos (Skitsanos) · GitHub (github.com)
2 upvotes·95 views
Needs advice
on
MongoDBMongoDBNode.jsNode.js
and
ReactReact

Hello,

I will be programming my project in the coming months. I would need advice on the technology I will use.

I focus mainly on mobile apps, so it's clear there that it will be a native app written in Kotlin.

I will also need a backend (database, API). In the database, I will need to store words and their translations along with users and some statistics to start with.

I don't know which database to choose, whether NoSQL or SQL. Maybe NoSQL would suffice for some words and key-value data.

I would like to connect the web and a chrome extension to that backend. I assume that chrome extensions are made in JavaScript and I would use either Vue.js, AngularJS, or React on the web. The web would be quite simple, some flashcards, statistics, and so on ... I don't know which framework would be ideal, I've never done it, I'll be basically learning it. Ideally, also where you need as little CSS as possible.

With that backend, I have a dilemma as to which framework to use. Basically, it will be such a new for me, I just played with Flask a little bit, but It doesn't matter. Basically, everything runs on JS except the Android app. So is it advantageous to choose Node.js on the backend? I have no experience with this, is it an advantage when everything runs in almost one language? I also thought about Flask / Django, but I also quite like Node.js since it's in JS. But I'm open to all the possibilities of .NET, Spring .... What would be your choice?

To summarize: Android App - Native app in Kotlin Chrome Extension - JavaScript (I don't know if it can be done in anything else) Web - Vue, Angular or React and that's JavaScript Database - SQL / NoSQL? - I don't know which is more suitable, or some specific types Backend - the dilemma of what language and framework to use

I'll write everything myself, it's a project for school, but I want to move it to a higher level and release it. If it doesn't work out, at least I'll learn something. Thank you for the answers.

READ MORE
9 upvotes·197.7K views
Replies (2)

Let's start with the database. First, in my experience, there are few applications where choosing a document database (NoSQL) over a relational database (SQL) is advantageous. While document databases are conceptually very straight forward, I find the tradeoffs down the road are simply not worth it (I wont get into all the details here, but please do some research on the downsides of NoSQL databases). If your data storage needs were exceedingly simple, I might reach for something from the Google Firebase suite, Realtime Database or Cloud Firestore; but I find even simple storage needs tend to expand and grow over time as your application matures. Postgresql is an excellent choice, and an absolute powerhouse for a ton of applications. With the somewhat recent additions of hstore, json, and jsonb datatypes, the advantages of reaching for a pure document datastore melt away.

For the Chrome extension, I would probably favour going for something a bit more lightweight than React or Angular. I'm a huge fan of React, but it comes with a somewhat hefty download, so if it were me, I might reach for Vue instead on that one. React is better for bigger, more complex single-page applications, whereas Vue is probably a better fit for simpler applications which require a smaller set of components.

For the backend, I would pick something mature with a strong and active community. Flask is a nice choice, but I've felt a bit "on my own" when using it in terms of community/documentation. I've used Rails extensively, but the learning curve is a bit of a headache; the time you'll save using Rails is very much down-the-road rather than immediate. If you're comfortable already with Javascript, then node + express is probably your best bet.

But, let me change my tune a little bit. You mentioned that this is a school project. In light of that fact I suggest you gravitate towards languages and frameworks that will help grow your career. Making smart choices based on the requirements of the task at hand is always prudent, but in this case I think it may be more valuable to gain some experience with some of the current "industry standard" stacks. Ask yourself what you can build a career on, and dabble in some of those areas until you find something that clicks for you. So, here are my revised answers, with options for each category ranked in order of preference

  • Database: PostgreSQL, MySQL
  • Backend: Node/Express, Rails, Django, Spring
  • Frontend: React, Angular, Vue
READ MORE
10 upvotes·11K views
Principal Engineer at Crowd Emotion / Element Human Ltd·

Hi Karin, I really liked your take on this whole school thing, I'm amazed you want to put such a huge effort in it.

And please appreciate your project is a lot to take and it can also be a lot to do: the risk is going beyond the assignment for the sake of exploring technologies, architecture styles, desing patterns, and so on, just for the sake of it (don't take me wrong, I've done it all my life).

So my first advice, as quite an experienced software developer, is always go back to some fundamental principles before starting anything, before thinking to anything, and perhaps the most important principle of all is KISS: Keep It Simple and Short (search it up, there are a few versions of what those letters represent :) ). In your case, since it's a school assignment, simplicity is even more important because it makes things clear which makes learning so much more effective.

When dealing with complex tasks like this, another fundamental element is focus: where should you keep your attention when designing and then developing a software product?

In this specific case, I lack what the original assignment was requesting, but I'm quite sure the point (or one of the points) was to make you think and then act on something that didn't require months to be developed, it was to make you learn how to accomplish a task without getting lost in details or in a project too big to be finished in a finite time.

I may be wrong, but I'll keep this in mind when writing the below lines.

FIrst, the architecture of the software product looks like a classic three tiered one: frontend, backend, database. Keep in mind another fundamental principle here: the separation of concerns, which leads to different decoupled architectural elements. Also, just for clarity, the frontend(s) will talk only with the backend, while the backend will talk with the database: this will help you isolate the database from the frontend, ideally enabling you to change database technology if needed.

Second, you explained you want to go web and mobile for the frontend tier: this inevitably will lead you to the conclusions you pointed out correctly, having to choose a number of platforms and languages to basically create the same application, but the fragmentation of different knowledge and procedures can make your life quite complicated and probably miserable.

Personally I'd go for native Android and React for web. Recently, though, I stumbled upon Flutter which, through the same codebase (in Dart, very similar to JavaScript) can create for you applications for mobile (Android and iOS) and the web: I tried it and I've been blown away by the effectiveness and easiness of using it.

For the backend, keep playing with Flask and build a RESTful API, all in all python is a language way more readable and maintainable than JavaScript, and with node.js is so easy to fall into the callback hell (recently less and less but still). Stay away from Java and its ecosystem if you want to finish you project at all (just kidding).

On the database tier, remember NoSQL databases can be quite powerful, but in your case try something very simple (redis can do), or just go with MongoDB as it makes easy to start and evolve your data structures. If you're more the structured type and you want to go RDBMS, try postgresql, it's easy to start (it has also NoSQL features) but so much more powerful and you could learn real SQL on it (stay away from the omnipresent MySQL, it's kind of odd sometimes).

I hope the above didn't sound too much of a lecture, and I also really hope you learn the most important lesson of all: always keep in mind the big picture!

READ MORE
7 upvotes·11.2K views
Needs advice
on
C#C#
and
GolangGolang

I need some advice to choose a language for back-end development. Right now, my REST APIs were created by using Flask/Django, and I'd like to create a more reliable and more efficient API with static typing. On the one hand, Go is young, very light, and syntax like Python's, but C# has a large number of libs and more built-in methods. Which is the best solution today?

READ MORE
8 upvotes·283.2K views
Replies (10)
Recommends
on
C#
Golang

It depends.

From times to times I asked or was asked that same question. Technology aside, it's important to consider the skills and expertise that the dev team has. Whether you use language A,B or C or framework X,Y and Z, if your team has a strong background and experience with something make it count too.

READ MORE
9 upvotes·280.2K views
Recommends
on
Golang
at

I would recommend Go simply because as you mentioned, it's super light. No need to bring in the whole .NET suite to get a simple REST API up and running. Even if your API is a bit complex, Go should be able to handle it.

READ MORE
6 upvotes·280.8K views
View all (10)
Needs advice
on
DjangoDjango
and
FlaskFlask

Hey, so I developed a basic application with Python. But to use it, you need a python interpreter. I want to add a GUI to make it more appealing. What should I choose to develop a GUI? I have very basic skills in front end development (CSS, JavaScript). I am fluent in python. I'm looking for a tool that is easy to use and doesn't require too much code knowledge. I have recently tried out Flask, but it is kinda complicated. Should I stick with it, move to Django, or is there another nice framework to use?

READ MORE
GitHub - memegamer138/Startup-success: This repository has all the information about the "Start-up success predictor" project. (github.com)
23 upvotes·1M views
Replies (7)

Try PyQT! Its very boring and plain but if you just need to push a few buttons, change a few sliders, it will do the job!

READ MORE
18 upvotes·1 comment·14.3K views
sunil vaishnav
sunil vaishnav
·
January 3rd 2021 at 7:57AM

thanks for this suggestion

·
Reply
Recommends
on
Django

Django has a built-in admin which can leverage a lot of repetitive stuff, auth framework, etc. But without more details on the type of app, I can't say it will pay the learning process. Django documentation is awesome. Take a look at the Django tutorial, it will help you decide if it is what you are looking for or not.

https://docs.djangoproject.com/en/3.1/intro/tutorial01/

READ MORE
4 upvotes·1.9K views
View all (7)