Code Monkey home page Code Monkey logo

keywatch-backend's Introduction

KeyWatch-backend

This guide helps you setup the backend server for the Chrome extension. The actual API is in the section below.

1. Set up PostgreSQL (version 11)

Mac:
Windows:

2. Clone this repo and install dependencies

  • Create a virtual environment for Python 3: https://docs.python.org/3/library/venv.html
    • virtual environments help manage dependencies and make sure Python code works across computers
  • Activate that virtual environment
  • Clone this repo somewhere
  • cd into the repo
  • Run "pip install -r requirements.txt" - this command downloads all the Python libraries needed to run the backend server

3. Run the server

  • cd into the repo if not in there already
  • Run "source setup.sh" - this sets up the environment variables
  • Run "python api.py"

4. Testing to make sure it worked

  • Open up another terminal window while the server is running
  • Activate your virtual environment
  • cd into the repo
  • Run "flask resetdb"
  • Run "flask add"
  • Go to "http://127.0.0.1:5000/" in your browser
  • You should see a JSON object - if you do, then it worked!

API

Resource URL

http://127.0.0.1:5000/

Resource Information

Response formats: JSON
Requires authentication: No

Parameters

Name Required Description Default Value Example
start_date No Start date of keystrokes (inclusive) None 2019-08-05
end_date No End date of keystrokes (inclusive) None 2019-08-07
limit No Limit on how many keystrokes to return (ordered by most recent) None 100

If no parameters are given, the default is to return all the keystrokes.

Examples

http://127.0.0.1:5000?start_date=2019-08-05&end_date=2019-08-07
This returns all the keystrokes between 2019-08-05 and 2019-08-07 inclusive.

http://127.0.0.1:5000?start_date=2019-08-05
This returns all the keystrokes after 2019-08-05 (inclusive).

http://127.0.0.1:5000?end_date=2019-08-07
This returns all the keystrokes before 2019-08-07 (inclusive).

http://127.0.0.1:5000?limit=100 This returns the last 100 keystrokes.

http://127.0.0.1:5000
This returns all the keystrokes in the database.

keywatch-backend's People

Contributors

loafyyy avatar

Watchers

Robin Zhang avatar  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.