Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mongodb-developer/flask-pymongo-example
Implementation of flask and pymongo using mflix sample data set and mflix python UI
https://github.com/mongodb-developer/flask-pymongo-example
flask mongodb-atlas pymongo pymongo-wrapper python3
Last synced: 6 days ago
JSON representation
Implementation of flask and pymongo using mflix sample data set and mflix python UI
- Host: GitHub
- URL: https://github.com/mongodb-developer/flask-pymongo-example
- Owner: mongodb-developer
- License: apache-2.0
- Created: 2021-07-05T08:05:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-19T10:03:35.000Z (4 months ago)
- Last Synced: 2025-01-07T20:09:48.041Z (14 days ago)
- Topics: flask, mongodb-atlas, pymongo, pymongo-wrapper, python3
- Language: Python
- Homepage:
- Size: 1.13 MB
- Stars: 62
- Watchers: 10
- Forks: 34
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flask-pymongo-example
```
$$$$$$$$\ $$\ $$\ $$$$$$$\ $$\ $$\
$$ _____|$$ | $$ | $$ __$$\ $$$\ $$$ |
$$ | $$ | $$$$$$\ $$$$$$$\ $$ | $$\ $$ | $$ |$$\ $$\ $$$$\ $$$$ | $$$$$$\ $$$$$$$\ $$$$$$\ $$$$$$\
$$$$$\ $$ | \____$$\ $$ _____|$$ | $$ |$$$$$$\ $$$$$$$ |$$ | $$ |$$\$$\$$ $$ |$$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\
$$ __| $$ | $$$$$$$ |\$$$$$$\ $$$$$$ / \______|$$ ____/ $$ | $$ |$$ \$$$ $$ |$$ / $$ |$$ | $$ |$$ / $$ |$$ / $$ |
$$ | $$ |$$ __$$ | \____$$\ $$ _$$< $$ | $$ | $$ |$$ |\$ /$$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |
$$ | $$ |\$$$$$$$ |$$$$$$$ |$$ | \$$\ $$ | \$$$$$$$ |$$ | \_/ $$ |\$$$$$$ |$$ | $$ |\$$$$$$$ |\$$$$$$ |
\__| \__| \_______|\_______/ \__| \__| \__| \____$$ |\__| \__| \______/ \__| \__| \____$$ | \______/
$$\ $$ | $$\ $$ |
\$$$$$$ | \$$$$$$ |
\______/ \______/
$$$\
$$ $$\
\$$$\ |
$$\$$\$$\
$$ \$$ __|
$$ |\$$\
$$$$ $$\
\____\__|
$$\ $$\ $$$$$$$\ $$$$$$$\ $$$$$$\ $$\ $$\
$$$\ $$$ | $$ __$$\ $$ __$$\ $$ __$$\ $$ | $$ |
$$$$\ $$$$ | $$$$$$\ $$$$$$$\ $$$$$$\ $$$$$$\ $$ | $$ |$$ | $$ | $$ / $$ |$$$$$$\ $$ | $$$$$$\ $$$$$$$\
$$\$$\$$ $$ |$$ __$$\ $$ __$$\ $$ __$$\ $$ __$$\ $$ | $$ |$$$$$$$\ | $$$$$$$$ |\_$$ _| $$ | \____$$\ $$ _____|
$$ \$$$ $$ |$$ / $$ |$$ | $$ |$$ / $$ |$$ / $$ |$$ | $$ |$$ __$$\ $$ __$$ | $$ | $$ | $$$$$$$ |\$$$$$$\
$$ |\$ /$$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ | $$ | $$ | $$ |$$\ $$ |$$ __$$ | \____$$\
$$ | \_/ $$ |\$$$$$$ |$$ | $$ |\$$$$$$$ |\$$$$$$ |$$$$$$$ |$$$$$$$ | $$ | $$ | \$$$$ |$$ |\$$$$$$$ |$$$$$$$ |
\__| \__| \______/ \__| \__| \____$$ | \______/ \_______/ \_______/ \__| \__| \____/ \__| \_______|\_______/
$$\ $$ |
\$$$$$$ |
\______/
```
## IntroductionImplementation 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 UIThe 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 requirements.txt
```Rename the `sample_ini` to `.ini`.
```
mv sample_ini sample.ini
```[Get your Atlas cluster](https://docs.atlas.mongodb.com/getting-started/) with [sample data](https://docs.atlas.mongodb.com/sample-data/) set [connection string](https://docs.atlas.mongodb.com/connect-to-cluster/) and place in `DB_URI` parameter under `.ini`
Make sure you have IP in the Atlas [access list](https://docs.atlas.mongodb.com/security/add-ip-address-to-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