Python Forum
General advice web application - flask - database - cms
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
General advice web application - flask - database - cms
Hello reader,

I've decided to retrain myself as a software engineer, since my educational background
greatly limits my intellectual scope as well as career possibilities (I hold a master in Korean language and culture). 
Deciding and realizing are two very different things, and in order to see whether programming could be my cup of tea
and to streamline my learning process, I've devised a project. I'd like some general advice
on how to implement this project. But first I'll list my learning approach and the details of the project.

I'm learning Python 3 through 'Learning Python 3 the hard way' by Zed Shaw
and 'Python Crash Course' by Eric Matthes. Combining these two agrees with me,
since their approach feels quite different. I would be helped by more
exercises with answer keys, though, in order to be able to generate code
more automatically by subjecting myself to repetition. Can you possibly direct me to such resources?

My project:
I plan to build a web application that allows high school students to listen to audio fragments
of Mandarin and answer questions about those fragments. These questions will be multiple choice,
so no need for Chinese characters yet, either from my end or from the user's end
(I might want to add this in the future, but will cross that bridge then). The input from users
is very useful information; I'd like to store that information in a database.
I will use 'Audacity' to create audio files. Entrance to the web application will be password-protected.

Steps so far:
- I've decided on Flask as a framework.
- I've acquired server space.
- Learning Python 3 like a madman.

Concrete questions:
1. What is a simple but good Flask-compatible CMS? Internet searches yield interesting lists of python-based
CMSs, but the majority seems to be compatible with Django. I'd like Flask.

2. My assumption is that I would use Python for the web application, and some other
language for the front-end. Is that correct? And if so, what language for the front-end? HTML?

3. What would I need to build a very simple database that stores the users' input?
(A very general question, I know. For now I need some general pointers, which I can use
to read up on the material and decide on further steps.)

Thank you for sitting through this wad of text. As you've seen, I'm a complete beginner. I do enjoy writing code,
and the prospect of building something practical is very enticing, but there is much to learn.
Any advice on the above would be greatly appreciated!
1) Most extensible cms' are built with Django in mind, as Django was built with them in mind (and it comes with a pretty decent admin interface, for almost no extra effort).  Flask, meanwhile, is a lot more barebones.  Using Flask, means you have more work ahead of you, but it'll be easier to use if there's something you want to do that doesn't fit into what Django wants you to be doing.  Personally, I prefer Flask.  For your case, I don't think the difference will matter that much.  But that's because I don't think you need a CMS.

You say you want to store the user's responses in a database.  You should ALSO have the questions themselves in the database.  Then, if you use a db admin tool (such as phpmyadmin), adding new questions will be fairly easy, which then eliminates your need for a cms entirely.

2) When it comes to web development, there's a few "extra" things you need to learn, right up front.  There's two different environments you're working with.  There's the server, where you can talk to the database, and build web pages out of what it says to you, and then there's the client, which is Joe Somebody sitting on their couch using your website on their iPhone 17.

Python can ONLY run on the server side.  Anything you want to actually show up in front of a person, on the client side, needs to be in a language the client's browser can understand.  For you, now, that language is HTML (with CSS to make it look pretty).  Javascript is combined with html to make it more dynamic, but that's probably more complexity than you need to worry about right now.

3) sql is the language of databases.  Getting data into, and out of, databases requires it's use.  ...or you can use an ORM, like sqlalchemy (which is very good, by the way):

There are many... brands, I guess, of databases.  sqlite comes "built in" to python, which means you can start using it, right now, without installing anything.  It's fine for small databases, but if this is something you intend to actually continue to use and support after you make it, I recommend using something different.  postregs is open source, free, and very good:
There's also mysql, which might be your only option depending on what your server is (for shared hosting, you're often now allowed to install programs, so you're limited to what's already there).
Microsoft's SQL Server is fine, but is not free.  Oracle's database (it's called Oracle.  And so is the company.  Try not to get confused :p  ) is used by big corporations, but is generally disliked by humans for being very hard to work with.  Also, not free.
IBM has db2, which I don't actually know very much about, but is not free.
Then there's a lot of other, less important, databases, like Mongo.  Or Visual FoxPro (which is something I had to work with in the past, and DO NOT recommend).

For added "fun", each database uses slightly different dialects of sql, so just "learning" sql isn't very helpful, as it'll work differently depending on the database.  Except for sqlite, which actually does a very good job of sticking to the standard.  This is actually another reason you should check out sqlalchemy, as it'll figure out what it needs to do depending on what you're connecting to, so you don't need to worry about it.

Like most things in life, this can be as easy or as difficult as you want it to be.  You can choose how deep down the rabbit hole you want to go.  For your use, postgres or mysql are both totally fine (...and overkill to be honest lol).

As to your actual question, you'll want a table for responses.  Every table should have a primary key (almost always called "id"), with a foreign key, which references which question that response is an answer for (normally called "otherTable_id", so here, maybe "question_id").  Then, the rest of the table depends on whether or not you're tracking their multiple-choice answer (in which case, another foreign key pointing to a table full of answers), or if it's a text box that they can type whatever they want into (in which case, the column type depends on the server type.  Some of them have a Text type, others use varchar(max), others (ab)use the Blob type, and I think there's something completely different Oracle does, because Oracle frequently does things in it's own special way).

...good luck?
Hi Nilamo,

Thanks for your extensive reply. It has helped me out a lot. I think I have a much better grasp of the different concepts and components as well as a grasp of the scope of the project. One question that arose after I've read your reply is whether I don't need to learn Javascript. The way I see it now - presumably wrong, but I'll go with it - is that I would use Python to build the application and to communicate with the various databases. HTML and CSS I would use to present the information to the user's browser. But since this is an application, I will need the user's input. In order words, the webpage will need to be interactive. Wouldn't I need Javascript for that?

I realize this is a beginner's question. I've done some research online concerning this particular question, but I haven't been able to identify a clear-cut, correct answer.

Kind regards,

In your browser, you can disable javascript. If you do that, most sites still work (including this one).

html has a <form> tag, and if there's a <input type="submit" /> tag within the form, then clicking that button will send the form's contents to the server. Which is how the entire internet worked before the cancer javascript spread as much as it has.

What you WOULD use javascript for, is to display a spinner, or "please wait" message while the form is being sent. It makes things nicer to work with, but it isn't required for it to work.
Hi @bashage

Take a look at this flask tutoral link. You might find it useful.
Is that your site? You should consider adding a clear div just above the footer, so your sidebar doesn't overlap it. :)

I am afraid not. I suck at writing.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Desktop Application that will connect o Azure SQL Database thewolf 7 1,659 Feb-26-2021, 01:33 AM
Last Post: thewolf
  Flask export/upload database table in cvs/xlsx format steve87bg 4 2,759 Jun-19-2020, 01:46 PM
Last Post: steve87bg
  MySQL Database Flask maurosmartins 0 867 Oct-03-2019, 10:56 AM
Last Post: maurosmartins
  [Flask] No application found. SheeppOSU 1 1,884 Jun-01-2019, 02:58 PM
Last Post: SheeppOSU
  Read Save RadioButtons from Database in Python Flask Webpage Gary8877 0 4,686 Apr-11-2019, 12:33 AM
Last Post: Gary8877
  flask sqlite jinja accessing and updating database help pascale 5 2,080 Feb-11-2019, 03:49 PM
Last Post: pascale
  how i save the html form to flask database mebaysan 1 5,119 Feb-07-2019, 12:56 AM
Last Post: snippsat
  General advice web application Ramzi 3 2,177 Jan-27-2018, 05:41 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020