Giter VIP home page Giter VIP logo

hello-app's Introduction

HelloWorld Flask App

This is a Hello World web application written in Flask.

Prerequisites

Below prerequisites must be fulfilled for successful execution of code.

Software Requirement

Resources in this repository are meant for use with Python 3.x (check the version using python3 --version) and pip3 (check the version using pip3 --version). If you don't have the compatible version, download it from official python repository.

Python Installation To install python3 and pip3 on ubuntu operating system using apt package manager, use below command.

    sudo apt update
    sudo apt install python3
    sudo apt install python3-pip

Bootstrap Virtual Environment

It is a best practice to create a virtual environment for your application to avoid any conflict in dependencies between multiple applications. Hence, We will need to create a virtual environment (using python's default package "venv") and install all the dependencies.

python3 -m venv helloworld-app-venv # on Windows, use "python -m venv helloworld-app-venv" instead
source helloworld-app-venv/bin/activate # on Windows, use "helloworld-app-venv\Scripts\activate" instead
pip install -r requirements.txt

Note:

  • Activation makes the virtual environment the default Python interpreter for the duration of a shell session. Because, This will prepend that directory to your PATH, so that running python will invoke the virtual environment’s Python interpreter. As an indication of virtual environment activation, current shell prompt will prepend the name of the virtual environment you are currently using.

  • To deactivate the environment, simply type deactivate and you will return to your normal shell.

  • Within the virtual environment, you can use the command pip instead of pip3 and python instead of python3.

Run and Test the App on Machine

To start the web server of the app, execute the below command -

    python run.py

To check the webapp, open a browser and go to URL -

    http://<IP>:Port
    http://127.0.0.1:8080/

Run and Test the App on Docker

  1. Clone the repository and switch inside the directory.
  2. Build the docker image using below command:
    docker build . -t helloworld-app-img:latest
  1. To run the docker container from built image in the background with port mapping, use below command:
    docker run -d -p 5000:8080 --name helloworld-container helloworld-app-img
  1. To test the app on host machine, open the browser or use curl command:
    curl http://localhost:5000

Note:

  • . tells docker about the path of the Dockerfile.
  • Port mapping is used to access the services running inside a Docker container. In the above case, we can now access the application using port 5000 on the host machine.

hello-app's People

Contributors

anupam-sy avatar

Watchers

 avatar

hello-app's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.