Giter VIP home page Giter VIP logo

flask-crud's Introduction

Flask Application for CRUD operations on MongoDB

How to run the application locally

There are two ways of running the application locally

  1. Using Docker
  2. Using normal python env

Using docker

  1. Make sure docker and docker compose is installed in your PC if not follow this steps
  2. Clone the project in to your local machine
  3. Run the following commands
cd <project_location>
docker-compose build
docker-compose up -d

This will run your application in localhost:5000 with mongodb running in port 27017

Using normal python env

  1. Clone the git repo to your local
  2. Install virtualenvironment in your pc
  3. Create a new virtual env
  4. Create a .env file with following env vars MONGO_URI APP_HOST APP_PORT
  5. Follow the commands
cd <project_location>
pip install -r requirements.txt
flask run

Follow either of one your application should be running locally

API Reference

Get all users

  GET /users

returns all the users in the batch of 10

Parameter Type Description
page int Optional defaultly we consider page as 1

Get a particular user

  GET /users/${id}
Parameter Type Description
id string Required. Id of the user to fetch details

Add a User

  POST /users
Parameter Type Description
name string Required.
email string Required. and should be valid email id
password string Required. and should be more than 6 chars long
  PUT /users/${id}
Parameter Type Description
id string Required. else you will get validation error
  DELETE /users/${id}
Parameter Type Description
id string Required. else you will get validation error

Screenshots

Get all users

Get all users

Get user by ID

Get user by id

Add User

Add user

Update user

Update user by id

Delete a user

Delete a user by id

Additional information

  1. In docker set up The mongo db is non-persistent When ever you start the application new db instance will be used
  2. There a script called populate.py this is used to pre-populate the users data with faker library you can run this script to pre-populate 100 user data

How to run populate.py script

Run the docker-compose up -d 
do docker ps
get the container id of flask_assignment_app
do docker exec -it <container_id> bash
you will get inside the container
then run python populate.py it should populate 100 users data

flask-crud's People

Contributors

anusha-s-navada 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.