This is a simple hello world
type OOP Flask application that can be used as a template for multiple uses.
Two endpoints with calls to a separate class returning JSON data to client.
Features:
- Docker enabled
- Flask v2.0.2
- Simple OOP
- 2 defined endpoints
- To do development through Docker only:
- To do development outside of Docker containers:
- Create a directory to save the code:
mkdir Workspace cd Workspace
- Download this repo:
git clone https://github.com/spaceshiptrip/DevSeries-Backend-Flask.git
- Change to the project directory
cd DevSeries-Backend-Flask
Note: This is not necessary if you are not using Docker.
-
Build the docker container:
docker build -t be:dev .
-
Run the app through the container:
docker run -it --rm -v $(PWD):/app -p 5000:5000 -e CHOKIDAR_USEPOLLING=true --name be --rm be:dev
-
Pre-requisites:
- Python 3
- Pip 3
-
Optional to run in virtual env
- Run the command to get into the virtual env
source bin/activate
- If errors are seen, run the command:
And install the virtualenv through the docs
rm -fr ./bin
- Run the command to get into the virtual env
-
Build the server
pip3 install -r requirements.txt
-
Run the server
python3 app.py
Test with either cURL commands:
- cURL (Windows MacOS)
curl http://localhost:5000/getSomeData curl http://localhost:5000/getSomeDataFromFile
- Dockerized version
- Open a terminal prompt
- If you used the run command listed above:
docker stop be
- Replace
be
if you chose another name which can be found for port5000
:docker ps
- Non Dockerized version
- In the terminal running the server, press <CTRL>-c