Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

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): https://www.sqlalchemy.org/

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: https://www.postgresql.org/
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?
buran likes this post
It's dangerous to go alone!  Take this: https://docs.python.org/3/library/index.html

Currently #4 in both post count, and rep. wavic and buran, I'm coming for you...
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.
It's dangerous to go alone!  Take this: https://docs.python.org/3/library/index.html

Currently #4 in both post count, and rep. wavic and buran, I'm coming for you...
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. :)
It's dangerous to go alone!  Take this: https://docs.python.org/3/library/index.html

Currently #4 in both post count, and rep. wavic and buran, I'm coming for you...

I am afraid not. I suck at writing.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Redirecting all Flask logs georgelza 0 61 Apr-18-2018, 12:48 PM
Last Post: georgelza
  Python /Flask Login with LDAP Auth pythonnubie 4 229 Apr-16-2018, 03:14 PM
Last Post: nilamo
  flask, I want to send a json from the front end and update it to the postgresql DB wi passion044 1 135 Apr-12-2018, 08:40 AM
Last Post: thomasp
  Flask - Opening second page via href is failing - This site can’t be reached rafiPython1 2 105 Apr-11-2018, 08:41 AM
Last Post: rafiPython1
  Insert results API in database daryl 2 161 Mar-16-2018, 08:32 AM
Last Post: thomasp
  Application like simpler facebook wall in python framework seidman 1 158 Mar-11-2018, 05:07 PM
Last Post: wavic
  Python Database Django gilesgerman 5 211 Feb-24-2018, 08:02 PM
Last Post: gilesgerman
  Creating portal for xwindows application abby007 0 164 Jan-30-2018, 07:00 PM
Last Post: abby007
  python3 + Flask + SQLite = HTTP 400 supertoy 5 411 Jan-30-2018, 02:13 PM
Last Post: supertoy
  General advice web application Ramzi 3 259 Jan-27-2018, 05:41 PM
Last Post: wavic

Forum Jump:

Users browsing this thread: 1 Guest(s)