A simple Python Todo Web App and a stripped-down version of https://github.com/UTCSheffield/python-web-oauth-orm-rest-starter. This version removes auth, admin, and API layers so you can concentrate on data classes and page routes.
- Flask based Python Webserver with routing (a function for each url endpoint users can visit)
- HTML / Jinja templates for looping though and outputting data.
- todo.py contains the endpoints for the Todo app
- SQL Databases the modern way
- Managed by SQLAlchemy an ORM / Object Relationship Mapper which allows you to write classes that define the data and provides the storage & CRUD for you.
- ORMs build the database for you from your classes so you define what you want to store how it connects together and any extras calculations / functions you need .
- Start with SQLite but you can move to professional systems like PostgreSQL or others when you are ready.
- todo.py includes the Todo class that provides all you need for the building of the database and all the CRUD.
- Login to github.com
- Go to the github repository https://github.com/UTCSheffield/python-web-orm-starter
- Click the green "Use this template" button at the top of the page
- Select "Create a new repository"
- Fill in your new repository details:
- Choose a repository name
- Add a description (optional)
- Choose Public or Private visibility
- Click "Create repository from template"
- Your new repository will be created with all the template files
Using GitHub Desktop:
- On the GitHub page for your new repository
- Click the green "Code" button
- Click "Open with GitHub Desktop"
- You may need to login to GitHub Desktop if you haven't already
- You may be prompted to choose a local path to clone the repository to
- Click 'Open in Visual Studio Code' to open the project in VS Code
Open a Terminal
py -m pip install -r requirements.txt # It may need python3 on some systemsStart the Flask development server:
py -m flask run # It may need python3 on your systenThe app will be available at http://localhost:5000
Try it and create a few tasks!
This code uses SQLAlchemy to set up classes that have methods to talk to many databases. We use SQLite for simplicity and easy local development.
The database file is stored in /instance/todo.db
Hopefully Visual Code has promoted you to install the recommended extensions including the SQLite extension. and so todo.db should appear in the left hand side explorer view with a red icon.
Have a look, can you see the tables and data?