{"id":19765896,"url":"https://github.com/gandresto/mongodb-m220p","last_synced_at":"2026-05-06T19:07:37.407Z","repository":{"id":37224057,"uuid":"263736386","full_name":"gandresto/MongoDB-M220P","owner":"gandresto","description":"Archivos del proyecto mflix, del curso M220P de MongoDB University","archived":false,"fork":false,"pushed_at":"2022-08-23T18:10:39.000Z","size":16970,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T00:12:48.783Z","etag":null,"topics":["course","flask","mongodb","pymongo","python3"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gandresto.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-13T20:29:52.000Z","updated_at":"2020-05-18T15:56:39.000Z","dependencies_parsed_at":"2022-06-22T07:33:27.418Z","dependency_job_id":null,"html_url":"https://github.com/gandresto/MongoDB-M220P","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gandresto%2FMongoDB-M220P","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gandresto%2FMongoDB-M220P/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gandresto%2FMongoDB-M220P/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gandresto%2FMongoDB-M220P/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gandresto","download_url":"https://codeload.github.com/gandresto/MongoDB-M220P/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241099554,"owners_count":19909570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["course","flask","mongodb","pymongo","python3"],"created_at":"2024-11-12T04:20:03.982Z","updated_at":"2026-05-06T19:07:37.376Z","avatar_url":"https://github.com/gandresto.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"=====\nmflix\n=====\n\nThis is a short guide on setting up the system and environment dependencies\nrequired for the MFlix application to run.\n\n\nProject Structure\n-----------------\n\nEverything you will implement is located in the ``mflix/db.py`` file, which\ncontains all database interfacing methods. The API will make calls to ``db.py``\nto interact with MongoDB.\n\nThe unit tests in ``tests`` will test these database access methods directly,\nwithout going through the API. The UI will run these methods in integration\ntests, and therefore requires the full application to be running.\n\nThe API layer is fully implemented, as is the UI. If you need to run on a port\nother than 5000, you can edit the ``index.html`` file in the build directory to\nmodify the value of **window.host**.\n\nPlease do not modify the API layer in any way, ``movies.py`` and ``user.py``\nunder the **mflix/api** directory. Doing so will most likely result in the\nfrontend application failing to validate some of the labs.\n\n\nLocal Development Environment Configuration\n-------------------------------------------\n\nAnaconda\n~~~~~~~~\n\nWe're going to use `Anaconda \u003chttps://anaconda.org/\u003e`_ to install Python 3 and\nto manage our Python 3 environment.\n\n**Installing Anaconda for Mac**\n\nYou can download Anaconda from their `MacOS download site\n\u003chttps://www.anaconda.com/download/#macos\u003e`_. The installer will give you\nthe option to \"Change Install Location\", so you can choose the path where the\n``anaconda3`` folder will be placed. Remember this location, because you will\nneed it to activate the environment.\n\nOnce installed, you will have to create and activate a ``conda`` environment:\n\n.. code-block:: sh\n\n  # navigate to the mflix-python directory\n  cd mflix-python\n\n  # enable the \"conda\" command in Terminal\n  echo \". /anaconda3/etc/profile.d/conda.sh\" \u003e\u003e ~/.bash_profile\n  source ~/.bash_profile\n\n  # create a new environment for MFlix\n  conda create --name mflix\n\n  # activate the environment\n  conda activate mflix\n\nYou can deactivate the environment with the following command:\n\n.. code-block:: sh\n\n  conda deactivate\n\n**Installing Anaconda for Windows**\n\nYou can download Anaconda from their `Download site\n\u003chttps://www.anaconda.com/download/\u003e`_. Please be careful to select ``Windows Tab`` before downloading.\n\nThe Anaconda installer will prompt you to *Add Anaconda to your PATH*. Select\nthis option to use ``conda`` commands from the Command Prompt.\n\nIf you forget to select this option before installing, no worries. The installer\nwill let you choose an \"Install Location\" for Anaconda, which is the directory\nwhere the ``Anaconda3`` folder will be placed.\n\nUsing your machine's location of ``Anaconda3`` as ``\u003cpath-to-Anaconda3\u003e``, run\nthe following commands to activate ``conda`` commands from the Command Prompt::\n\n  set PATH=%PATH%;\u003cpath-to-Anaconda3\u003e;\u003cpath-to-Anaconda3\u003e\\Scripts\\\n\nOnce installed, you will have to create and enable a ``conda`` environment.\n\n.. code-block:: sh\n\n  # enter mflix-python folder\n  cd mflix-python\n\n  # create a new environment for MFlix\n  conda create --name mflix\n\n  # activate the environment\n  activate mflix\n\nYou can deactivate the environment with the following command:\n\n.. code-block:: sh\n\n  deactivate\n\n\nVirtualenv\n~~~~~~~~~~\n\n*Note: If you installed Anaconda instead, skip this step.*\n\nAs an alternative to Anaconda, you can also use ``virtualenv``, to define your\nPython 3 environment. You are required to have a Python 3 installed in your\nworkstation.\n\nYou can find the `virtualenv installation procedure`_ on the PyPA website.\n\nOnce you've installed Python 3 and ``virtualenv``, you will have to setup a\n``virtualenv`` environment:\n\n.. code-block:: sh\n\n  # navigate to the mflix-python directory\n  cd mflix-python\n\n  # create the virtual environment for MFlix\n  virtualenv -p YOUR_LOCAL_PYTHON3_PATH mflix_venv\n\n  # activate the virtual environment\n  source mflix_venv/bin/activate\n\nYou can deactivate the virtual environment with the following command:\n\n.. code-block:: sh\n\n  deactivate\n\n.. _`virtualenv installation procedure`: https://virtualenv.pypa.io/en/stable/installation/\n\nPlease remember that you may have to reactivate the virtual environment if you\nopen a new Terminal or Command Prompt window, or restart your system.\n\n\nPython Library Dependencies\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nOnce the Python 3 environment is activated, we need to install our python\ndependencies. These dependencies are defined in the ``requirements.txt`` file,\nand can be installed with the following command:\n\n.. code-block:: sh\n\n  pip install -r requirements.txt\n\n\nMongoDB Installation\n~~~~~~~~~~~~~~~~~~~~\n\nIt is recommended to connect MFlix with MongoDB Atlas, so you do not need to\nhave a MongoDB server running on your host machine. The lectures and labs in\nthis course will assume that you are using an Atlas cluster instead of a local\ninstance.\n\nThat said, you are still required to have the MongoDB server installed, in order\nto be able to use two server tool dependencies:\n\n- ``mongorestore``\n\n  - A utility for importing binary data into MongoDB.\n\n- ``mongo``\n\n  - The MongoDB shell\n\nTo download these command line tools, please visit the\n`MongoDB download center \u003chttps://www.mongodb.com/download-center#enterprise\u003e`_\nand choose the appropriate platform.\n\n\nMongoDB Atlas Cluster\n---------------------\n\nMFlix uses MongoDB to persist all of its data.\n\nOne of easiest ways to get up and running with MongoDB is to use MongoDB Atlas,\na hosted and fully-managed database solution.\n\nIf you have taken other MongoDB University courses like M001 or M121, you may\nalready have an account - feel free to reuse that cluster for this course.\n\n*Note: Be advised that some of the UI aspects of Atlas may have changed since\nthe inception of this README, therefore some of the screenshots in this file may\nbe different from the actual Atlas UI interface.*\n\n\nUsing an existing MongoDB Atlas Account:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you already have a previous Atlas account created, perhaps because you've\ntaken one of our other MongoDB university courses, you can repurpose it for\nM220P.\n\nLog-in to your Atlas account and create a new project named **M220** by clicking\non the *Context* dropdown menu:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_create_project.png\n\nAfter creating a new project, you need to create a **mflix** free tier cluster.\n\n\nCreating a new MongoDB Atlas Account:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you do not have an existing Atlas account, go ahead and `create an Atlas\nAccount \u003chttps://cloud.mongodb.com/links/registerForAtlas\u003e`_ by filling in the\nrequired fields:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/atlas_registration.png\n\n\nCreating a free tier cluster called \"mflix\":\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n*Note: You will need to do this step even if you are reusing an Atlas account.*\n\n1. After creating a new project, you will be prompted to create the first\n   cluster in that project:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_create.png\n\n\n2. Choose AWS as the cloud provider, in a Region that has the label\n   ``FREE TIER AVAILABLE``:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_provider.png\n\n\n3. Select *Cluster Tier* M0:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_tier.png\n\n\n4. Set *Cluster Name* to **mflix** and click \"Create Cluster\":\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_name.png\n\n\n5. Once you press *Create Cluster*, you will be redirected to the account\n   dashboard. In this dashboard, make sure you set your project name to **M220**.\n   Go to ``Settings`` menu item and change the project name from the default\n   **Project 0** to **M220**:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_project.png\n\n\n6. Configure the network settings of this cluster in the **Network Access** tab,\n   so you can connect from your IP address. When you select ``ADD IP ADDRESS``,\n   the menu that appears may give you the option to add ``ADD CURRENT IP\n   ADDRESS``. This is preferable, but if this option does not appear, please\n   select ``ALLOW ACCESS FROM ANYWHERE``:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/whitelist_an_ip_address.png\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/add_whitelist_entry.png\n\n7. Then create the application MongoDB database user required for this course:\n\n  - username: **m220student**\n  - password: **m220password**\n\nYou can create new users through *Security* -\u003e *Add New User*.\n\nAllow this user the privilege to ``Read and write to any database``:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_application_user.png\n\n\n8. When the user is created, and the cluster deployed, you have the option to\n   ``Load Sample Dataset``. This will load the Atlas sample dataset, containing\n   the MFlix database, into your cluster:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/load_sample_dataset.png\n\n**Note: The MFlix database in the Sample Dataset is called \"sample_mflix\".**\n\n\n9. Now you can test the setup by\n   connecting via ``mongo`` shell. You can find instructions to connect in the\n   \"Connect\" section of the cluster dashboard:\n\n.. image:: https://s3.amazonaws.com/university-courses/m220/cluster_connect_application.png\n\nGo to your cluster *Overview* -\u003e *Connect* -\u003e *Connect Your Application*. Select\nthe option corresponding to your local MongoDB version and copy the ``mongo``\nconnection string.\n\nThe below example connects to Atlas as the user you created before, with\nusername ``m220student`` and password ``m220password``. You can run this command\nfrom your command line:\n\n.. code-block:: sh\n\n  mongo \"mongodb+srv://m220student:m220password@\u003cYOUR_CLUSTER_URI\u003e\"\n\nBy connecting to the server from your host machine, you have validated that the\ncluster is configured and reachable from your local workstation.\n\nThe connection string you used to connect will be used in your MFlix application\nas well.\n\n\nImporting Data (Optional)\n-------------------------\n\n**Note: if you used Load Sample Dataset, you can skip this step.**\n\n**Note: if you used Load Sample Dataset, you can skip this step.**\n\nThe ``mongorestore`` command necessary to import the data is located below. Copy\nand paste the command, and replace ``\u003cyour-atlas-uri\u003e`` with your Atlas SRV\nstring:\n\n.. code-block:: sh\n\n  # navigate to mflix-python directory\n  cd mflix-python\n\n  # import data into Atlas\n  mongorestore --drop --gzip --uri \u003cyour-atlas-uri\u003e data\n\n\nRunning the Application\n-----------------------\n\nIn the ``mflix-python`` directory there are two files, called ``dotini_unix``\nand ``dotini_win``.\n\nRename this file to ``.ini`` with the following command:\n\n.. code-block:: sh\n\n  mv dotini_unix .ini  # on Unix\n  ren dotini_win .ini # on Windows\n\nOnce the file has been renamed, open it, and enter your Atlas SRV connection\nstring as directed in the comment. This is the information the driver will use\nto connect!\n\nTo start MFlix, run the following command:\n\n.. code-block:: sh\n\n  python run.py\n\n\nAnd then point your browser to `http://localhost:5000/\u003chttp://localhost:5000/\u003e`_.\n\n\nRunning the Unit Tests\n----------------------\n\nTo run the unit tests for this course, you will use ``pytest``. Each course lab\ncontains a module of unit tests that you can call individually with a command\nlike the following:\n\n.. code-block:: sh\n\n  pytest -m LAB_UNIT_TEST_NAME\n\nEach ticket will contain the command to run that ticket's specific unit tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgandresto%2Fmongodb-m220p","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgandresto%2Fmongodb-m220p","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgandresto%2Fmongodb-m220p/lists"}