In this repository I have mentioned about some methods by which we can show our outputs of flask app. These methods would proof very handy in the development and testing phase of app and will reduce your depedancy on front end team for interface development.
Please refer below sections and follow the step by step approach.
- Create a folder Flask_App and move into same
mkdir Flask_App
cd Flask_App
- Create a file 01-Constant_Inputs.py and copy paste code from 01-Constant_Inputs.py
touch 01-Constant_Inputs.py
- Run a file 01-Constant_Inputs.py in spyder or run through command line interface
python3 01-Constant_Inputs.py
-
Click below URL's to check the outputs
For Addition Click Me For Substraction Click Me -
Now you can read and try to understand code written in 01-Constant_Inputs.py and for any questions feel free to reach out to me on linkedin Shubham Patil
Here in this section we will see how can we pass inputs through URL
- Create a folder Flask_App and move into same
mkdir Flask_App
cd Flask_App
- Create a file 02-Inputs_Through_URL.py and copy paste code from 02-Inputs_Through_URL.py
touch 02-Inputs_Through_URL.py
- Run a file 02-Inputs_Through_URL.py in spyder or run through command line interface
python3 02-Inputs_Through_URL.py
- Click below URL's to check the outputs. Here you can put any value of a and b and it will give you addition and substraction.
- e.g If you want to do addition of 10 and 20 then URL should be http://localhost:8000/addition?a=10&b=20
For Addition Click Me For Substraction Click Me
- e.g If you want to do addition of 10 and 20 then URL should be http://localhost:8000/addition?a=10&b=20
- Now you can read and try to understand code written in 02-Inputs_Through_URL.py and for any questions feel free to reach out to me on linkedin Shubham Patil
Here in this section we will use swagger to pass inputs to app, which would be very convinient in development phase
- Create a folder Flask_App and move into same
mkdir Flask_App
cd Flask_App
- Create a file 03-Inputs_Through_Swagger.py and copy paste code from 03-Inputs_Through_Swagger.py
touch 03-Inputs_Through_Swagger.py
- Run a file 03-Inputs_Through_Swagger.py in spyder or run through command line interface
python3 03-Inputs_Through_Swagger.py
-
Click below URL's to open swagger.
Click Here To Go To Swagger -
Click On [addition] or [substraction] drop down=> click on [Try it Out] => Enter First and Second number=> Click [Execute] => Check output in [Response body]
Click Here To Go To Swagger
-
Now you can read and try to understand code written in 03-Inputs_Through_Swagger.py and for any questions feel free to reach out to me on linkedin Shubham Patil
Here in this section we will see how to connect HTML page with flask app to take inputs and show outputs
- Create a folder Flask_App and move into same
mkdir Flask_App
cd Flask_App
- Create a file 04-Inputs_Through_HTML.py and copy paste code from 04-Inputs_Through_HTML.py
touch 04-Inputs_Through_HTML.py
- Create a folder templates and create a file index.html and copy paste code from index.html
mkdir templates
cd mkdir
touch index.html
- Run a file 04-Inputs_Through_HTML.py in spyder or run through command line interface
python3 04-Inputs_Through_HTML.py
-
Click below URL's to open swagger.
Click Here To Open App URL -
On App page, Enter First and Second number and then enter SUM or SUB for addition and substraction respectively.
-
Now you can read and try to understand code written in 04-Inputs_Through_HTML.py and for any questions feel free to reach out to me on linkedin Shubham Patil
Among above methods we can choose any one to see our app output while developing any flask application.