This backend has a RESTful API to interact with the Selficient home.
This project uses Flask for the development server, unit testing support and a RESTful API.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
You need:
- Python version 3.6.x to create a virtual environment and install the dependencies for this project
- 'pip' and 'py' as ENVIRONMENT VARIABLES (Windows)
- MariaDB running locally on your machine
A step by step series of examples that tell you how to get a development env running
Clone the repo.
git clone https://github.com/WyTho/python_flask.git selficient-python-api
Change directory to the project folder
cd selficient-python-api
Setting up a virtual environment on Linux or MacOS
Install virtual environments for Python
py -m pip install --user virtualenv
Setup a virtual environment in the project folder
py -m virtualenv env
Activate the virtual environment
.\env\Scripts\activate
Optional: More information about virtual environments
Install the dependencies in the virtual environment
pip install -r requirements.txt
You should have a MariaDB instance running on your local machine.
For debugging purposes it's handy to have a GUI for the database like HeidiSQL or Database Workbench. Some IDE's (like PyCharm) can connect to the database too.
Create a user for the DB with username: dev and password: secret
Create a database schema called WySmart
Import the database schema by running:
manage.py db upgrade
Run the following command to seed some dummy data into the database:
manage.py seed
This adds an example graph with its data called AVERAGE_TEMPERATURE
The dummy data can be processed into averages using the Put call on /api/graph/AVERAGE_TEMPERATURE
Run
app.py
Run the test version of the application
test_app.py
Run in separate window
test_manage.py run_tests
├── controllers (1)
├── migrations (2)
├── models (3)
├── processing (4)
└── tests (5)controllerscontains the resources that handle incoming requestsmigrationscontains the history of the database, these are used to initiate and update the databasemodelscontains the businesslogic and database connectionprocessingcontains scripts that are used to analyse event data in order to create graphstestscontains the tests for this project.
- Rolf de Sterke - Initial work - Github page
See also the list of contributors who participated in this project.