GithubHelp home page GithubHelp logo

devop's Introduction

Time Web Application

Table of Contents

About The Project

This project is the part of the Innopolis University DevOps course. The aim of the project is to get acquainted with the Python best practices and frameworks for developing web applications using the example of a small web application that shows the current time in Moscow.

Built With

Flask Pylint markdownlint Docker

Getting Started

Following the instructions below, you can create a local copy of the project and run the Time web application, which will show the current time in Moscow.

Prerequisites

My main development environment is Visual Studio Code, so all further steps will be determined to work in this particular IDE. If you do not have VS Code installed, then you can download it from this !link or use this tutorial to get started with Flask if you want to use any other development environment.

  1. Install the Python extension to VS Code.

  2. Make sure that you have. You can download from python.org.

  3. On Windows, make sure the location of your Python interpreter is included in your PATH environment variable. You can check the location by running path at the command prompt. If the Python interpreter's folder isn't included, open Windows Settings, search for "environment", select Edit environment variables for your account, then edit the Path variable to include that folder.

  4. Make sure you have already installed both Docker Engine and Docker Compose. You don’t need to install Python or Redis, as both are provided by Docker images.

Installation

Run this command in your Terminal to clone the repository:

git clone https://github.com/Amina19058/DevOps.git
cd DevOps
git checkout lab3

Activate the project environment

At this point, you will activate your Python environment and install Flask using the pip package installer.

  1. Open VS Code, make sure that you are in the project directory.

  2. Open the Command Palette (View > Command Palette. Then select the Python: Select Interpreter command. From the presented list, select the virtual environment in your project folder that starts with ./.venv or .\.venv.

  3. Run Terminal: Create New Terminal from the Command Palette.

  4. Use the following command to create and activate a virtual environment named .venv based on your current interpreter:

    # Linux
    sudo apt-get install python3-venv 
    python3 -m venv .venv
    source venv/bin/activate
    
    # macOS
    python3 -m venv .venv
    source venv/bin/activate
    
    # Windows
    py -3 -m venv .venv
    venv\scripts\activate
  5. Also in the Terminal, run the following command to update pip:

    python3 -m pip install --upgrade pip
  6. Then, run this to install the requirements:

    python3 -m pip install -r requirements.txt

Run the app

  1. Move to code directory:

    cd src
  2. Run the app.py by python3 -m flask run, which runs the Flask development server. The development server looks for app.py by default. When you run Flask, you should see output similar to the following:

    (venv) amina@Aminas-MacBook-Air src % python3 -m flask run         
    * Debug mode: off
    WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
    * Running on http://127.0.0.1:5000
    Press CTRL+C to quit

    If you see an error that the Flask module cannot be found, make sure you've run python3 -m pip install flask in your virtual environment as described at the end of the previous section.

  3. See the result on http://127.0.0.1:5000. You also can use the Live Server in VSCode.

  4. Stop the app by using Ctrl+C in the terminal.

Getting Started With Docker

Before running the application, please install all the prerequisites:

Docker installation

  1. Make sure you have already installed both Docker Engine and Docker Compose. You don’t need to install Python or Flusk, as both are provided by Docker images.

  2. Run this command in your Terminal to clone the repository:

git clone https://github.com/Amina19058/DevOps.git
cd DevOps
git checkout lab3

Run docker

  1. In the project directory open the Terminal and start up the application by running:

    docker-compose build
    docker-compose up
  2. See the result on http://127.0.0.1:8000.

  3. Stop the app by using Ctrl+C in the terminal.

Unit Testing

  1. Make sure that you are in the application directory:

    cd DevOps
  2. Run the tests:

    pytest .

Best practices of Unit Testing are also described in PYTHON.md

Usage

You can use this project for educational purposes. All the steps above allow you to launch an application that shows the current time in Moscow.

During their execution, you will learn how to create and activate a virtual environment, install Flask and develop simple web applications.

Also, in the PYTHON.md file you can find information about the best Python and Unit Testing practices, the advantage of Flask, why to use linters.

And in the DOCKER.md file you can find information about the best Dockerfile practices, what linters to use.

Contributing

I will gladly accept any contributions you make, as we will be able to make this project better together. Moreover, each of us will gain incredible experience in creating web applications and the correct design of the project.

If you have a suggestion that would make this project better, do not hesitate to contact me or fork the repo and create a pull request.

Contact

Amina Khusnutdinova - [email protected]

Project Link: https://github.com/Amina19058/app_python

Acknowledgments

devop's People

Contributors

amina19058 avatar

Watchers

 avatar

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.