Coder Social home page Coder Social logo

sniffr-be's Introduction

sniffr-be

The backend of sniffr, an application for finding play dates for your dog. ๐Ÿ•

Project Stack

A python flask app, which is dockerizerd

Want to run this in developlment?

First-Time Setup

  1. Clone the backend repo to a folder on your machine.
    clone this repo

  2. Move into the cloned repo with:

cd sniffr-be
  1. If you are going to be changing code then switch to a new branch using:
git checkout xxxx
  1. Add a blank file called .env into the repo so the app can pull sensitive information. Fill the .env file with the information from the .env pinned message in our discord.
    env file

  2. Set up a virtual environment (a mini python development workspace) using pipenv by running pipenv install when in the app's base directory:
    ๐Ÿšจ This step will produce more code than just shown below and could take a few minutes depending on dependancy installation / your machine.
    pipenv install

  3. Activate your environment by running pipenv shell as the prompt says. This will load the things you placed in .env and activate the necessary python imports.
    pipenv shell

  4. We need to set up the database next. You are going to run three commands in sequence into your bash terminal once you have started your pipenv shell in step 6:

        flask db init  
        flask db migrate  
        flask db upgrade  
    

    The above commands will set up the initial sqlite db, create a migration script that will set up the db as we have written it in models.py, and the third command will run the migration script (2) and upgrade (3) our initial (1) sqlite database.

    ๐Ÿ’ป You should end up with a folder called migrations/ and the file sniffrdb.db, which contains our blank tables, if everything went well.

  5. Lastly, we need to seed our database with starter information. To do so, run python seed_db.py when in the base directory to activate the seed script. If successful, it should print out new entries in each of the tables that were seeded. Example:
    seed db output

Running the app (after the first-time installation steps above)

Supposing you did steps 1-8 above already...

  1. Make sure you are in the correct branch!

  2. Then activate your pipenv shell:

    pipenv shell

    pipenv shell 2

  3. Once active, you can run the flask app:

    flask run

    flask run

    โœ”๏ธ This should run up the app. You can view the exact url and port you need in the output. And now you can now use curl , postman , thunder client , or a browser to access routes

๐Ÿ’ก Hint: Did you make changes to models.py??

If you made changes to models.py during development... you do not need to completely remake the database. Instead, you can migrate and upgrade the database (usually). Try running: flask db migrate flask db upgrade If successful, then you should be able to seed and use the new database tables/columns. If not, you may need to remake it from scratch after deleting the sniffrdb.db file and migrations folder.

Heroku Commands

heroku run bash --app sniffr-be

Testing Commands

To run all of the tests:

pytest -v tests/sniffr_tests

To run coverage analysis:

pytest tests/sniffr_tests --cov=sniffr 

DOCKER -- UNDER CONSTRUCTION

If you want to quickly run a docker container of this app then you can:

  1. Download the repo
  2. Run docker-compose up --build

Docker Container Usage

  1. docker start sniffr-be...
  2. docker stop sniffr-be...

Backend Routes

Run w/ Postman

sniffr-be's People

Contributors

jae-finger avatar allie-rae avatar danimal-johnson avatar do159hu avatar deusexmashima avatar

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.