Needs advice

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)

7 upvotes76.7K views
Replies (3)

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

5 upvotes3.8K 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.

5 upvotes3.8K views
View all (3)
Avatar of flashing-blinkenlights