Building APIs - First Full Web Application Development
I spent 30 days learning Python and ultimately built a full-fledged web application using Flask, MongoDB, APIs, and HTML. What started as a simple challenge completely changed how I understand web development and the technology behind modern websites.
This post concludes my efforts of going through the 30 Days Of Python by Asabeneh Yetayeh on GitHub. I began with some preliminary knowledge in coding from my studies and thus, found this more of a reboot than a complete new introduction.
The Python programming language has been intriguing to say the least. Usually, when coding, you’ve got to code in different languages and learn different terms; however, for this, it was almost like coding in one language and doing nearly everything from it.
As I’ve repeated many times, I do still use ChatGPT to help me learn the programming language and logic. While I’m no expert, it does increase my comprehension by being able to get it to explain blocks of code to me and what each code does.
I don’t want to include all the code I did for creating this project, making it seem as though I have magically gained coding skills in 30 days. Rather, I’ll upload my final project to GitHub and have you view it from there.
Objective
Create a fully functioning web application with Flask, MongoDB, and Python that does the following:
- Text analyser:
- Takes a piece of text and dissects it for different types of information, like word count, character count, and lexical density of a word against the text.
- API Usage:
- Should use an external NoSQL database created with MongoDB that allows users of the website to view, update, add, and delete rows in the database from the website.
- Jinja2 Templates:
- Uses a templating system to render information from Python scripts directly into our HTML code to load on the website.
- Python Functions:
- Create and embed Python functions into the website to create functions like the text analyser mentioned above.
- Database:
- The API should point to a live database, which is a separate entity.
Project Successes
The overall website looks like a fully functioning web application when launched on a local development environment and after being hosted on Render for free.
The database was created fine and smooth with no issues at all, and I would describe that task as being the easiest. When it came to building the Text Analyser with Python, I found that it was relatively easy, also because by this point in coding, I had been coding with Python continuously for 29 days during this course.
The obstacles I faced were more with using Flask functions, as I even got used to using the Jinja2 templating quite quickly. One of the troublesome features to build was the ‘update a student’s details’ function, as I could retrieve information from the database and display that on my website using Jinja2 templating, but didn’t necessarily know how to have a selected student from a list have their details display in a separate page and form box ready to edit.
I then turned to ChatGPT to help me learn how to use the matplotlib module in Python to graph data in the database. This would technically be the dashboard of the website statistics.
While I would describe my own efforts as being poor because I had to consult ChatGPT throughout the build of this function, I would still go ahead and continue to build applications using the same database and API for this function alone until it makes complete sense.
Here is the link to my project 👉 Flask Website You can also view my GitHub Repository for it 👉 Flask Website Repo
Please refrain from downloading anything from the internet and have anti-virus software/solution in place
It’s time to move over to JavaScript and see how well I can do there, and revisit both these topics numerous times.
I would highly recommend this course to anyone who wants to get into coding with Python and learn how to create web applications.
Update: I have made a second edition to the website as I wasn’t pleased with the overall folder structure and felt like the design could be a lot better.
