Giter Club home page Giter Club logo

flask-app's Introduction

Flask API for Managing Orders Data

This Flask API allows users to manage orders data stored in a PostgreSQL database. The API provides endpoints for creating, reading, updating, and deleting orders.

Prerequisites

Before setting up and running the Flask API application, ensure you have the following prerequisites installed:

  • Docker
  • Kubernetes

Setup

Follow the steps below to set up and run the Flask API application:

  1. Clone the repository:

    $ git clone https://github.com/yourusername/flask-app.git
    $ cd flask-app
    
  2. Build the Docker image for the Flask application:

    $ docker build -t flask-api .
  3. Build the Docker image for the Mocker:

    $ docker build -t mock-data .
  4. Create a Kubernetes cluster either in the cloud or locally. Make sure kubectl is configured to access the cluster.

  5. Create a PostgreSQL database instance or use an existing one.

Install Helm:

$ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Run to install psql:

$ helm repo add bitnami https://charts.bitnami.com/bitnami 
$ helm install postgres bitnami/postgresql
$ helm get notes postgres
  1. Apply the Kubernetes manifests to deploy the Flask application and run job to store order data into the database:
    $ kubectl apply -f job.yml
    $ kubectl apply -f app.yml
    
  2. Verify that the pods and services are running:
    $ kubectl get pods
    $ kubectl get svc   
    
  3. Access the Flask API:
  • Get the external IP address of the Flask application service:
    $ kubectl get svc flask-service
    
  • Use tools like cURL or Postman to send HTTP requests to the API endpoints, using the obtained IP address. For example:
    $ curl http://<flask-service-external-ip>/orders
    
  1. Test the API by making requests to different endpoints:
  • Create a new order: POST /order
  • Get an order: GET /order/<order_id>
  • List all orders: GET /order
  • Search an order: GET /order/search?q=<product_name>
  • Delete an order: DELETE /order/<order_id>

Dependencies

The Flask API application has the following dependencies:

  • Flask
  • psycopg2

These dependencies are included in the requirements.txt file.

Additional Information

The Flask API handles errors and returns appropriate HTTP status codes:

  • 404 - Not found if the data is not found
  • 401 - Invalid request
  • 405 - Method not allowed

flask-app's People

Contributors

vedant-kakde 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.