https://github.com/vedant-kakde/flask-app
https://github.com/vedant-kakde/flask-app
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vedant-kakde/flask-app
- Owner: vedant-kakde
- Created: 2023-06-22T18:35:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T07:06:17.000Z (almost 2 years ago)
- Last Synced: 2025-01-01T06:42:13.740Z (5 months ago)
- Language: Python
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```shell
$ git clone https://github.com/yourusername/flask-app.git
$ cd flask-app2. Build the Docker image for the Flask application:
```shell
$ docker build -t flask-api .
```3. Build the Docker image for the Mocker:
```shell
$ 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:
```shell
$ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
```Run to install psql:
```shell
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm install postgres bitnami/postgresql
$ helm get notes postgres
```6. Apply the Kubernetes manifests to deploy the Flask application and run job to store order data into the database:
```shell
$ kubectl apply -f job.yml
$ kubectl apply -f app.yml7. Verify that the pods and services are running:
```shell
$ kubectl get pods
$ kubectl get svc8. Access the Flask API:
- Get the external IP address of the Flask application service:
```shell
$ 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:
```shell
$ curl http:///orders9. Test the API by making requests to different endpoints:
* Create a new order: POST /order
* Get an order: GET /order/
* List all orders: GET /order
* Search an order: GET /order/search?q=
* Delete an order: DELETE /order/## Dependencies
The Flask API application has the following dependencies:
* Flask
* psycopg2These 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