Set up Dwelling Flask Testing Backend (for the first time) NOTE: Database is SQLite3 via SQLAlchemy
- Github Repo: {https://github.com/codeforpdx/dwellinglybackend}
- Live Server: {https://dwellinglyapi.herokuapp.com/ }
-
Fork the backend and clone a copy ( https://help.github.com/en/github/getting-started-with-github/fork-a-repo )
-
Install Python ( https://realpython.com/installing-python/ )
-
Install virtualenv onto system (if not already installed)
- Mac + Linux:
python3 -m venv env
- Windows:
python -m venv env
- Mac + Linux:
-
Install dependencies while in main directory of dwellinglybackend forked copy
pip3 install --no-cache-dir -r requirements.txt
-
Create virtual environment:
virtualenv env
- To install virtualenv:
pip3 install --user virtualenv
-
Activate the virtual environment
- Mac + Linux:
source env/bin/activate
- Windows:
source env/Scripts/activate
- Mac + Linux:
-
Start the server using the flask environment (required every time the project is re-opened):
- Run:
pipenv run flask run
- Run + restart the server on changes:
pipenv run flask run --reload
- To install pipenv:
pip3 install --user pipenv
- Run:
Queries can be made with the Postman Collection link ( https://www.getpostman.com/collections/a86a292798c7895425e2 )
###Endpoints
How to contribute to this project.
- Set your origin to https://github.com/codeforpdx/dwellinglybackend.git
- The Main Branch is Development
~$: git pull origin development
- Branch from Development
~$ git checkout -b <name of branch>
go to
method | route | action |
---|---|---|
POST | /register/ |
Creates a new user |
GET | /users/ |
Gets all users (dev only) |
GET | /users/:uid |
Gets a single user (admin only) |
PATCH | /users/:uid |
Updates a single user |
POST | /login |
Login a single user |
POST | /user/archive/:uid |
Archives a single user (admin only) |
DELETE | /users/:uid |
Deletes a single user (admin only) |
###This Backend Uses JWT for authorization
Authorization header format:
Authorization Bearer < JWT access token >
###The database is seeded with 3 default users
[{
"email": "user1@dwellingly.org",
"password": "1234",
"firstName": "user1",
"lastName": "tester",
"archived": "false",
"role": "admin"
},
{
"email": "user2@dwellingly.org",
"password": "1234",
"firstName": "user2",
"lastName": "tester",
"archived": "false",
"role": "admin"
},
{
"email": "user3@dwellingly.org",
"password": "1234",
"firstName": "user3",
"lastName": "tester",
"archived": "false",
"role": "admin"
}]
method | route | action |
---|---|---|
POST | /properties/ |
Creates a new property (admin only) |
GET | /properties/ |
Gets all properties |
GET | /properties/:id |
Gets a single property (admin only) |
PATCH | /properties/:id |
Updates a single property |
PUT | /properties/:id |
Updates a single property (admin only) |
DELETE | /properties/:id |
Deletes a single property (admin only) |
POST | /properties/archive/:id |
Archives a single property (admin only) |
{
"id": "property1",
"name": "Garden Blocks",
"address": "1654 NE 18th Ave.",
"zipCode": "97218",
"city": "Portland",
"state": "OR",
"archived": False
},
method | route | action |
---|---|---|
POST | /user/message |
Send Message to a user |
{
"userid": 1,
"title": "Test email title",
"body": "Dwellingly Test email body"
},