Today I did a good amount of restructuring and replanning on how I want to handle this project. As I was looking into how to do front end development with JavaScript I began to get really lost as I was trying to connect it all back to the backend Python side of it. Not good considering on that side of things I am still learning and as such my knowledge is shaky. Thankfully I came across another tutorial from the Youtuber TechWithTim on creating a website (which can be found here:
Python Website Full Tutorial), where he uses a Flask backend and but uses Jinja with Bootstrap in the html to simplify that side of the project so the focus could be on the back end.
I restructured the project to better organized the files as the project grew. I created a 'website' package to store just about everything except for app.py, see below.
In it is of course the init.py file, signaling that the folder is a package. That file contains the following code:
app.py is where the app launches from, the static folder is future proofing for JavaScript/TypeScript files in the future and in a similar vein, the models.py will be for modelling the sql database down the line. The templates folder contains all the .html files. Thanks to Jinja making the html as been a lot easier. It allows you to make a base template file to act as a skeleton for the rest of your production html files to build off of reducing the amount of code you have to write.
The init.py file is what allows the website folder to be seen as a Python package by app.py. It contains the code below
def init_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = "nC1iuUeNlNe"
from .views import views
from .auth import auth
app.register_blueprint(views, url_prefix='/')
app.register_blueprint(auth, url_prefix='/')
return app
After creating the Flask app it grabs the pages designed/specified in the views.py and auth.py files so they can be reached by the app.
While there is still no actual functionality I was able to build some pages for the sign up and log in pages
All code can be found at the link below :)
webchat


Top comments (0)