Skip to content

iamAngelSH/flask-docker-hello-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fun Flask App on a Docker container

This is a very simple and generic Flask App that uses GET and Post methods. It also uses a fun API.


How to use:

  1. Clone this repository to a directory of your choice on your terminal.
  • Command to clone:
git clone https://github.com/iamAngelSH/flask-docker-hello-world.git
  1. Step in the repository directory
  • Change Directory
cd flask-docker-hello-world
  1. Here you should have all the contents you need.
  2. Having Docker running already on your computer, we can get started with the Flask App.
  3. Let's build the image
  • Run docker-compose up in the same directory you are in
docker-compose up

THESE NEXT STEPS IS TO USE THE FLASK APP ON THE WEB 🕸️

  1. Open a web browser
  • Once the image is the done building you should get the following link:
  • However, we will not be using that!
    • Since port 5000 is for the server running on the docker container, we need to use the port running on our local machine.
    • Use the following:
  1. Congrats 🥳 Flask App is up and running. You will see a menu on your web browser with what you can do on this Flask App.

Running a program to hit each of our flask app routes without looking at the web browser

Although we do have our flask app running, it is always good to test our routes and make sure they work appropriately.

  1. Having your flask docker container still running, open a new terminal.
  • Change into the directory that you have the repository (Flask Project) stored in.
    • Change into the repository directory
cd ~Path_to_repo
  1. Once you are in the reposiotry directory, we run another docker-compose command
  • This command will let us execute a python script to test the routes in our flask app and should return values via the terminal.
docker-compose exec web python make-requests.py
  1. Once you run this command, there will be results logged on your terminal.
  • If the status code is 200 (ok), you will get the following:
pong! 
EDIFNOC
4
  • If the status code is not 200, you will see something similar to the following:
{'code': 400, 'name': 'Bad Request', 'description': 'Failed to decode JSON object: None'} 
  1. Tada!! 🥳 You have hit all the targets in the flask app!

About

Flask App doing GET & POST requests.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published