Testing blog for testing things
- Actual post page
- Likes (WIP)
- Comments
- System for
threaded comments (Backburner)
- System for
- User profile
- Different media type posts (video, audio, pic)
- Blog sections
- Pagination
- Websockets (see likes realtime)
- The
API- Api was attempted but should really be moved into it's own service!
To set up the app, you'll need some things installed:
- python 3
- pip
- git
If installing on linux, please make your your package manager is up-to-date and you have python 3.6 or higher
and python3-venv
installed.
-
First of all, create and navigate to a directory in which you'd like to store the project. E.g.
C:\Dev\
-
Clone the project with
git clone https://github.com/BokChoyWarrior/flaskr
. In windows you'll need to run this from git bash terminal Make sure you clone into the directory you made in step 1! -
Change your current directory to
xyz/flaskr/
, so if you ran the clone command inC:\Dev\
, you would now want to be insideC:\Dev\flaskr\
-
Create a virtual environment with
- Windows:
python -m venv venv
- Linux:
python3 -m venv venv
- Windows:
-
Activate the virtual environment:
- Windows:
venv\Scripts\activate.bat
- Linux:
source venv/bin/activate
- Windows:
-
Install required packages with
pip install -r requirements.txt
-
Set environment variables:
set FLASK_APP=flaskr
set FLASK_ENV=development
export FLASK_APP=flaskr
export FLASK_ENV=development
-
Initialise database
flask init-db
-
Run the app with
python run.py
(windows), orpython3 run.py
(linux)
You should see output similar to this:
* Serving Flask app "flaskr"
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 855-212-761
Visit http://127.0.0.1:5000/ to see the app!
If you have any problems with installation let me know and I can help figure them out!
To run some unit tests, you'll first need to install the project to the venv as a module.
-
With the venv active, and in the root directory of the repository, use the command
pip install -e .
. -
You can then use command
pytest
to run the tests, orcoverage run -m pytest
to see the code coverage of said tests.
More detailed explanation on the flask tutorial site.