Skip to content

Surveillance Program Example using python3 (Flask Framework)

Notifications You must be signed in to change notification settings

asrulsibaoel/surveillance-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-streaming-Face-Detection-using-python-opencv

stream video of Face detection using opencv background subtraction and python Flask microframework

Introduction

This project is made for anyone who is looking for an example of how to create a rest endpoint using Python and Flask.

This service calls a local sqlite database. Please see databases directory for more details.

This projet was written using PyCharm Community Edition.

Installing Project Dependencies

This project uses Pipenv for virtual environment management.

If you are on MacOS you can install the dependency using homebrew:

brew install pipenv

Next run the following command to install the dependencies on your local computer:

pipenv install

Running the application

After you have performed all the dependency installations from above, you can run the following command on your terminal to start this app.

From the root of this project enter the following terminal command:

pipenv run python app.py

Or you can also start the application using PyCharm.

Project Database

This project uses a local sqlite for a repository.

Swagger

This project contains a swagger ui.

For more information regarding swagger. Click here.

For more information regarding connexion. Click here.

To view this api's swagger ui, run this application, then navigate to [http://localhost:5000/ui/]

You can test out this api entirely from the swagger ui page.

Rest Api

Users Api

GET - getAll: users/v1

GET - getByUsername: users/v1/darth

PUT - updateUserEmail: users/v1/darth + include a json body with new email.

DELETE - deleteUsername: users/v1/darth

Locations Api

GET - getAll: locations/v1

GET - getByState: locations/v1/ca

PUT - updateCapital: locations/v1/ca + include a json body with new capital.

DELETE - deleteLocation: locations/v1/ca

TDD - Integration Tests

This api is fully tested with Unit Tests and Integration tests. Please see tests directory for examples.

Tests connect to test.db for integration tests.

Flask Project

This project is a Flask project. For more information click here

Docker

This application can be run in Docker. Please see Dockerfile for image setup. Steps to create an image & how to run the app in a container list below. (must have docker installed)

Create a docker image: docker build -t flask-api .

Run docker container: docker run -it -p 5000:5000 flask-api

*** Once app has started, view the swagger ui by navigating to [http://localhost:5000/ui/] ***

View docker images: docker images

View docker containers: docker ps -a

Remove docker images: docker rmi $(docker images -q)

Remove docker containers: docker rm $(docker ps -aq)

Click here for more information regarding docker

* Note: this flask app by default runs as a development server, not meant for production. Docker & gunicorn is used to productionize this app. This docker container runs as as a production WSGI server, with 4 workers via gunicorn. *

Continuous Integration(CI)

A web hook has been setup with Travis CI for all Push and Pull Requests.

Questions / Contact / Contribute

Feel free to fork this repo, add to it, and create a pull request if you like to contribute.

If you have any questions, you can contact me via email: [email protected]

About

Surveillance Program Example using python3 (Flask Framework)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published