项目作者: magnusoy

项目描述 :
SmartPark-Server runs the REST-API server and provide a functional web interface.
高级语言: Python
项目地址: git://github.com/magnusoy/SmartPark-Server.git
创建时间: 2019-01-07T21:38:35Z
项目社区:https://github.com/magnusoy/SmartPark-Server

开源协议:MIT License

下载


SmartPark-Server

SmartPark-Server contains a website and has a REST-API.
This solution is supposed to run on a Raspberry Pi, but will work with linux, windows computers aswell.
It is possible to run the application alone as seen in the Examples, but you will have to download the client application for full functionality.
With doing so you will be able to add your own parkinglot and mark the parkingspots accordingly.

Go to SmartPark-Client for more imformation setting it up.

Prerequisites

You will need Python 3 for using the provided files.
Furthermore you will need to install all the dependencies listed below.

Install Python 3

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install python3-dev libffi-dev libssl-dev -y

Installing

Clone or download repository to your home directory.

  1. cd ~
  2. git clone https://github.com/magnusoy/SmartPark-Server.git

Install dependencies

  1. cd ~/SmartPark-Server
  2. pip3 install -r requirements.txt
  3. or
  4. pip3 install Flask==1.0.2
  5. pip3 install Flask-Mail==0.9.1
  6. pip3 install flask-marshmallow==0.9.0
  7. pip3 install Flask-WTF==0.14.2
  8. pip3 install Flask-SQLAlchemy==2.3.2
  9. pip3 install marshmallow==2.16.3
  10. pip3 install marshmallow-sqlalchemy==0.15.0
  11. pip3 install PyJWT

You will have to change some settings if you want a working contact page.

  1. cd SmartPark-Server/instance
  2. sudo nano config.py

Then change MAIL_USERNAME and MAIL_PASSWORD to yours.
Press CTRL+O and then ENTER to save changes.
Press CTRL+X to exit.

Examples

To run development server :

  1. cd ~/SmartPark-Server
  2. export FLASK_APP=app.py
  3. flask run

Press Ctrl+C in the terminal to close the server.

The development server will now run on: http://localhost:5000/

You will now also be able to use the REST-API

  1. curl -GET http://localhost:5000/parkinglots
  2. curl -GET http://localhost:5000/parkinglots/{id}

You will be able to POST, PUT and DELETE only by a valid token.
You can recieve a valid token by login

  1. curl --user magnusoy:password http://localhost:5000/login

Check if your token is valid

  1. curl -GET http://localhost:5000/protected?token={yourtoken}
  2. {"message":"This is only available for people with valid tokens."}
  1. curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"Parkinglot", "location":"62.733471,7.1434657", "size":20, "empty":20}' http://localhost:5000/parkinglots?token={yourtoken}
  2. {"empty":20,"id":39,"location":"62.733471,7.1434657","name":"Parkinglot","size":20}

Usage

There is also made a SmartPark-Client application which comes with an UI.
The Client application will take care of all the API calls by updating the
status of your parkinglot.

Go to SmartPark-Client for more imformation setting it up.

To run development server :

  1. cd ~/SmartPark-Client
  2. flask run

Press Ctrl+C in the terminal to close the server.

The development server will now run on: http://localhost:5000/

Output

Built With

Contributing

If you want to contribute or find anything wrong, please create a Pull request, or issue addressing the change, or issue.

Author

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Libraries

Flask

Flask-Mail

Flask-Marshmellow

Flask-WTF

Flask-SQLAlchemy