Skip to content

wicaksonoleksono/mvc-flask-mongo-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-mongodb template MVC

this project is a Template that utilies pymongo and mongodb as the database

Prerequisites

  • Python 3.11: This project requires Python 3.11. Make sure you have it installed on your machine.

Installing Dependencies

For Pipenv Users

If you prefer using Pipenv to manage your virtual environment and dependencies, follow these steps:

  1. Install Python 3.11 and Pipenv: Ensure you have Python 3.11 installed and then install Pipenv if you haven't already:

    pip install pipenv
  2. Create and Activate the Pipenv Environment: Use the following command to create a Pipenv environment with Python 3.11:

    pipenv install --python 3.11
  3. Install Dependencies: Once the environment is created, install the dependencies listed in the requirements.txt file:

    pipenv run pip install -r requirements.txt

For Pip Users

If you're using pip directly (without Pipenv), follow these steps:

  1. Create a Virtual Environment: Create a virtual environment using Python 3.11:

    python3.11 -m venv venv
  2. Activate the Virtual Environment:

    • On Windows:
      venv\Scripts\activate
    • On macOS/Linux:
      source venv/bin/activate
  3. Install Dependencies: With the virtual environment activated, install the dependencies using pip:

    pip install -r requirements.txt

Database Setup

Make sure you have MongoDB installed and running on your machine. You’ll need to configure your connection settings in the application to connect to your MongoDB instance. Lookup .env.example as a guide

SERVER_USERNAME=user_name
SERVER_PASSWORD=password 
CLUSTER_NAME =your_cluster_name
DB_NAME=your_database_name
SECRET_KEY=Rahasia123!

Running the Application

Once you have installed all dependencies and set up the database, you can run the application:

pipenv run python index.py

or

python index.py

(depending on whether you're using Pipenv or pip).

Running pytest for api testing/ unit testing.

go to the test directory then , run this naming conventions for pytest you can refer to this Documentation

pytest --cov=your_package_name --cov-report=term-missing

example :

pytest --cov=app --cov-report=html 

This checks your coverage then print it to html that you can open using quokka or Live server This is the example of the output expected in the html

unit_test

Documentation

this template provide documentation using OpenApi's Swagger from the flasgger library

to acess your swagger-UI (view) use acess it through
{{your_base_url}}/apidocs

this is what will you expect from acessing it swagger

Additional Notes

  • If you're contributing to the project, please make sure to follow the same Python version and environment setup to avoid any compatibility issues.
  • Feel free to add more instructions based on your project's specific needs.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages