Skip to content

ibrahima1289/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple calculator

I. Introduction

For this project, we will build the web app with Python Flask first, and we will check if it works in the local host.
Then, we will create a repo in github and upload all the files in that repo.
Also, we will use AWS Beanstalk to integrate the project.
Finally, we will create a project in Jenkins, link it to the calculator repo.

The calculator built in this repository is not complete yet. It is an ongoing project.
The resources used to build the simple calculator are from this link.

There are three features:

  • BMI Calculator: returns BMI (Body Mass Index).
  • Simple Calculator: as said, this is a simple calculator that do basic calculation. You can only input two values per operation.
  • Unites Converter (under construction)

II. Setting up the environment in VS Code:

Installation Flask in Python using visio code (Windows 10) Flask requires Python 3

Setup virtual environment

Create an environment

$ mkdir app_directory
$ cd app_directory
$ py -3 -m venv virtual

Activate the environment

$ .\virtual\Scripts\activate

Install Flask

$ pip install Flask

In the app_directory folder, create a folder application_app and a Python file where the code will be displayed.

Create a static and templates folder in application_app folder. In the static folder, create a CSS file for the style if needed. In the templates folder, create a HTML file(s).

Once the setup is done, import your codes in the correct files. Now you can check locally if your web app works.

III. Set up AWS Beanstalk

  1. Create your AWS account user.

  2. After you log in into your AWS root account, add a IAM user account with AWS Beanstalk privilages. Make sure to attach existing policies and save both access and secret key for future use.

  3. Log out from the root account, and log in into the IAM account.

  4. Go to Amazon Elastic Beanstalk and create an application.

  5. In create a web app, put the application name, add tag(s), and select python platform.
    Select sampke application > create application.

  6. It may take few minutes to set up th environment. Be patient!

  7. See AWS Elastic Beanstalk for more set up information.

  8. You should see this after the set up is done.

IV. Set up Jenkins

  1. Create an EC2 on AWS and set up Jenkins. Here is a tutorial from AWS.

  2. Log in to your Jenkins account.

  3. Go to Plugins Manager > Type AWSEB under Avalaible plugins.

  4. Select AWSEB Deployment and Cloubees Creadentials > Install.

  5. After updating the plugins, create a new project with github and AWS Beanstalk linked to the Jenkins project.

  6. When the project is done, build it on Jenkins.

  7. Go back to Elastic Beanstalk > Environments > Simplecalc-env, and launch the web application by following the URL highlighted in red.

    Then it will take you to the web application home page.

    First, the BMI calculator looks like this:

    And the simple, edited calculator looks like this:

V. Changes made to the calculator

From the source codes vr025, I was able to add two new features which are calculating the square root of a number and square a number.

This was easy to add because the syntax of the source code remains the same. I just had to copy/paste the line code and update the different variables.
For this, it is possible to upgrade this Simple Calculator into a Scientific one with more features.

The errors I ran into was mostly indentation of the lines in the codes.

Source:

  1. AWS
  2. Jenkins
  3. CSS, Js, and some Python codes for the simple calculator are from vr025.
  4. Flask set up from this link.
  5. For the BMI calculator, this resource was used.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages