Code Monkey home page Code Monkey logo

flask-pymongo-example's Introduction

flask-pymongo-example

$$$$$$$$\ $$\                     $$\               $$$$$$$\            $$\      $$\                                               
$$  _____|$$ |                    $$ |              $$  __$$\           $$$\    $$$ |                                              
$$ |      $$ | $$$$$$\   $$$$$$$\ $$ |  $$\         $$ |  $$ |$$\   $$\ $$$$\  $$$$ | $$$$$$\  $$$$$$$\   $$$$$$\   $$$$$$\        
$$$$$\    $$ | \____$$\ $$  _____|$$ | $$  |$$$$$$\ $$$$$$$  |$$ |  $$ |$$\$$\$$ $$ |$$  __$$\ $$  __$$\ $$  __$$\ $$  __$$\       
$$  __|   $$ | $$$$$$$ |\$$$$$$\  $$$$$$  / \______|$$  ____/ $$ |  $$ |$$ \$$$  $$ |$$ /  $$ |$$ |  $$ |$$ /  $$ |$$ /  $$ |      
$$ |      $$ |$$  __$$ | \____$$\ $$  _$$<          $$ |      $$ |  $$ |$$ |\$  /$$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |      
$$ |      $$ |\$$$$$$$ |$$$$$$$  |$$ | \$$\         $$ |      \$$$$$$$ |$$ | \_/ $$ |\$$$$$$  |$$ |  $$ |\$$$$$$$ |\$$$$$$  |      
\__|      \__| \_______|\_______/ \__|  \__|        \__|       \____$$ |\__|     \__| \______/ \__|  \__| \____$$ | \______/       
                                                              $$\   $$ |                                 $$\   $$ |                
                                                              \$$$$$$  |                                 \$$$$$$  |                
                                                               \______/                                   \______/                 
       $$$\                                                                                                                        
      $$ $$\                                                                                                                       
      \$$$\ |                                                                                                                      
      $$\$$\$$\                                                                                                                    
      $$ \$$ __|                                                                                                                   
      $$ |\$$\                                                                                                                     
       $$$$ $$\                                                                                                                    
       \____\__|                                                                                                                   
                                                                                                                                   
                                                                                                                                   
                                                                                                                                   
$$\      $$\                                         $$$$$$$\  $$$$$$$\         $$$$$$\    $$\     $$\                             
$$$\    $$$ |                                        $$  __$$\ $$  __$$\       $$  __$$\   $$ |    $$ |                            
$$$$\  $$$$ | $$$$$$\  $$$$$$$\   $$$$$$\   $$$$$$\  $$ |  $$ |$$ |  $$ |      $$ /  $$ |$$$$$$\   $$ | $$$$$$\   $$$$$$$\         
$$\$$\$$ $$ |$$  __$$\ $$  __$$\ $$  __$$\ $$  __$$\ $$ |  $$ |$$$$$$$\ |      $$$$$$$$ |\_$$  _|  $$ | \____$$\ $$  _____|        
$$ \$$$  $$ |$$ /  $$ |$$ |  $$ |$$ /  $$ |$$ /  $$ |$$ |  $$ |$$  __$$\       $$  __$$ |  $$ |    $$ | $$$$$$$ |\$$$$$$\          
$$ |\$  /$$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |      $$ |  $$ |  $$ |$$\ $$ |$$  __$$ | \____$$\         
$$ | \_/ $$ |\$$$$$$  |$$ |  $$ |\$$$$$$$ |\$$$$$$  |$$$$$$$  |$$$$$$$  |      $$ |  $$ |  \$$$$  |$$ |\$$$$$$$ |$$$$$$$  |        
\__|     \__| \______/ \__|  \__| \____$$ | \______/ \_______/ \_______/       \__|  \__|   \____/ \__| \_______|\_______/         
                                 $$\   $$ |                                                                                        
                                 \$$$$$$  |                                                                                        
                                  \______/                                                                                         

Introduction

Implementation of flask and pymongo using mflix sample data set and mflix python UI

This is a short guide on how to integrated MongoDB Atlas to Flask applications using Flask-PyMongo wrapper and pymongo driver.

Project Structure

The mflix directory holds the application logic.

  • db.py Where all database CRUD patterns are exposed as functions.
  • api/movies.py Where the web api is exposed to the UI

The main directory holds the following files:

  • run.py Where the Flask application is initialize and the config is loaded
  • sample_ini Where the connection URI to MongoDB Atlas is configured
  • requirments.txt Where the dependencies this project needs to run are located.

How to set-up

Clone the repository.

git clone [email protected]:mongodb-developer/flask-pymongo-example.git

Start a python virtual env:

# navigate to the flask-pymongo-example directory
cd flask-pymongo-example

# create the virtual environment for MFlix
python3 -m venv mflix-venv

# activate the virtual environment
source mflix_venv/bin/activate

Install dependencies

python3 -m pip install -r requirments.txt

Rename the sample_ini to .ini.

Get your Atlas cluster with sample data set connection string and place in DB_URI parameter under .ini

Make sure you have IP in the Atlas access list and username/password of your Atlas user correctly specified.

Start the application

python ./run.py

Open your browser on http://localhost:5000

Disclaimer

Use at your own risk; not a supported MongoDB product

flask-pymongo-example's People

Contributors

lucecarter avatar pash10g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask-pymongo-example's Issues

Tutorial misspells requirements.txt

the tutorial asks you to run :
python3 -m pip install -r requirments.txt

However the name of the file is requirements.txt

So run:
python3 -m pip install -r requirements.txt

Python Virtual Environment command in README.md is incorrect

Start a python virtual env:

# navigate to the flask-pymongo-example directory
cd flask-pymongo-example
# create the virtual environment for MFlix
python3 -m venv mflix-venv
# activate the virtual environment
source mflix_venv/bin/activate

In this code, line 4 has mflix-venv while line 6 has mflix_venv (first is a hyphen, second is an underscore)

Missing requirement

My version asks for package bson (for which it installs version 0.5.10).
Here's my poetry file with all requirements:

[tool.poetry.dependencies]
python = "^3.10"
flask = "^2.2.3"
faker = "0.8.13"
jupyter = "1.0.0"
jupyter-client = "5.2.4"
jupyter-console = "6.0.0"
jupyter-core = "4.4.0"
flask-cors = "^3.0.10"
bson = "^0.5.10"
pymongo = "^4.3.3"
flask-pymongo = "^2.3.0"

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.