This is the simplest possible API to interact with the UI in impossibilicus-web
- Flask - minimal python web framework
- Flask-RESTful - library that adds helpful REST conventions to Flask
- Python 2.7
- Python's
piplibrary- It might be installed with Python already - try just running the command
pipto test - If that fails, Pip Installation Guide
- It might be installed with Python already - try just running the command
virtualenv(Flask's documentation onvirtualenvis my favorite)- MongoDB (Documentation), confirm installation by running
mongod
- Start Mongo with
mongod(if you're running Mongo locally, otherwise it just needs environment varibles set to reference the hosted DB) - From the project directory, create/activate a virtual environment (step-by-step instructions also in Flask's
virtualenvdocs) - Install the project dependencies with
pip install -r requirements.txt - Environment variables that need to be set for the app to work:
MONGODB_URI,MONGO_USERNAME(these live permanently in Heroku, I'm not committing them because even though this is private now, something something commit history)- Optionally,
FLASK_DEBUG=1to enable flask's debug mode, which will live update the app when changes are made and display more detailed error outputs
- Optionally,
- Start the API with
python app.py - Confirm that it is running by accessing
http://localhost:5000/ - Use any REST client to make API calls (I use Insomnia)
- Application is automatically deployed on Heroku when a new commit is pushed to master. The web app that interacts with this API can be found here: https://immense-oasis-52264.herokuapp.com/
- Connect (requires Mongo installed):
mongo ds147510.mlab.com:47510/database_name -u username -p password - Empty out a collection ("story"):
db.story.remove({})