-1

I'm writing a Flask blog app.
I think that it some kind a heavy way to use database to store every post content. Is there a nicer way to implement this?
Is it a good way to use things like static site? If it's so, how to do this?

funkid
  • 577
  • 1
  • 10
  • 30

1 Answers1

0

If you want blog posts to be stored over multiple user sessions, you must use some kind of database and ORM. The most common ORM used with flask is SQLAlchemy. There is lots of good documentation for using Flask and SQLAlchemy together.

However, if you are not married to Flask, Django might be a good alternative, because it has a built in ORM and very good documentation for it already.

Extra: You can get pretty far with Flask

Sam Hollenbach
  • 652
  • 4
  • 19
  • Thanks for your advice. What I want to do is to write a personal blog app like [this](https://geelaw.blog/). I know SQLAlchemy and will use it for storing things like posts titles. What I wonder is that is it a good way to use database to store the post content and render it in the dynamic template to do things in [this question](https://stackoverflow.com/questions/54192339/include-specific-js-css-files-in-specific-blog-posts-a-flask-app). Is it a good try to set up an `assets` folder for each post like [this](https://geelaw.blog/) blog do (and that will be things like static site)? – funkid Jan 17 '19 at 02:42
  • You should be able to just store the blog content in another database field. You can have fields up to 2GB in size in SQL, I believe. In terms of the dynamic template, you could just pass boolean values into the `render_template` function determining if you need this libraries to run, and use an `if` statement within the template to call ` – Sam Hollenbach Jan 17 '19 at 22:51