It is web app developed with Javascript and Flask (Python) as back-end to test my fullstack abilities.
Based on a popular web app, the objective is to guess the word with a limited number of attempts. The user can change the parameters of # of letters and attempts.
Video Demo:
Follow these steps to set-up the project (detailed instructions are shown further down):
pip install -r requirements.txt
to install dependencies.env
filepip install flask
pip install python-dotenv
pip install requests
pip install flask-sqlalchemy
Go to rapidapi.com, sign up and select the Basic plan for Words API.
Be sure to copy the API key into the .env
file.
Furthermore, Flask needs a secret key to store session variables. We can create one ourselves by entering the following commands into the python interpreter.
>>> import os
>>> print(os.urandom(24).hex())
And copy the random string into the .env
file.
We can use environment variables with python-dotenv
and Flask to hide secrets such as API keys.
(See this for help on how to use environment variables with flask)
Create a file named .env
and add the following lines:
RAPID_API_KEY = {KEY GOES HERE}
SECRET_KEY = {KEY GOES HERE}
Type the following line in the .py file where the main Flask app is located.
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///DB_NAME.sqlite3'
Notice the "///" (three forward slashes) as it is important to create the database file in the root directory of the project folder (relative path).
Follow the quickstart guide from the docs to create the table structure (schema) of the db:
# Import from app.py
from app import app
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy(app)
class User(db.Model):
...
Then we run in the python terminal the following command to create the tables:
>>> from app import db
>>> db.create_all()
flask run
The project has the following tree structure:
.
├── README.md (Readme file)
├── app.py (Flask backend)
├── database.py (Database configuration)
├── static
│  ├── app.js (Main javascript frontend code)
│  ├── register.js (Js file for register.html)
│  ├── favicon.ico (Website icon)
│  └── style.css (Styles sheet)
├── templates
│  ├── register.html
│  ├── layout.html (Main HTML layout using Jinja templates)
│  └── index.html (Main website)
The main things I learned after developing this web app are:
Thank you!