Skip to content

fpozzobon/flask

Repository files navigation

flask API

Implementation of a simple flask API using MongoDB.

Pre requirements

  • Install and run MongoDB (ideally 3.6.0)
  • Install Python (idealy Python 3)

Quickstart

Use the Makefile

Or

Install env :

$ easy_install pip && \
  pip install virtualenv && \
  virtualenv env && \
  . env/bin/activate && \
  make deps

Install dependencies :

$ pip install -r requirements.txt

Setup the environment variables :

$ export FLASK_APP=flask_initdb.py
$ export FLASK_API_DB_URL=mongodb://localhost:27017/<yourcollection>>

Note : databaseUrl is optional, if not used the application will connect to mongodb://localhost:27017/flask

Database manipulation :

Populate the database (add data and indexes)

$ flask initdb

Note : the database won't be populated if there is already some documents in songs collection

Clean the database (empty songs collection):

$ flask cleandb

Run the project :

$ python flask_api.py

Finally open in your browser http://127.0.0.1:5000.

Unit Tests

Run the unit tests :

$ py.test tests

Run the integration-'ish' tests : (only /songs is tested)

$ python flask_integration_tests.py

Possible enhancements

  • [Optimisation] : use cache on main controller
  • [Optimisation] : limit the number of result after a search or add a pagination ?
  • [Database] : parse release date as a Date
  • [Tests] : cover all the tests

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published