Skip to content
No description, website, or topics provided.
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
api.py
employee.db
requirements.txt

README.md

Flask-Employee-API

Simple API for Employees to keep track of job tasks with user authorization.

pip install -r requirements.txt

My config.py file is inside .gitignore, so you have to create a config file manually.

Example:

import os

class DevConfig(object):
    SQLALCHEMY_DATABASE_URI = "sqlite:///C:\\users\\user\\employee.db"
    DEBUG = True
    SECRET_KEY = 'Your_Secret_Key'

Test the API with Postman or something similar.

Run:

python api.py

Employees

Login with test account that has admin rights:

http://127.0.0.1:5000/login GET method

In postman (or a similar service) go to authorization, choose basic authorization and for username type test and for password test.

This should give you a token which expires within an hour.

Now go to headers and add key with the name x-access-token and add your token to the value section.

Check all of the employees:

Doesn't work if you're not an admin.

http://127.0.0.1:5000/employee

Here you should see a list of employees with public id's, that public id is used to remove, promote etc. employees.

Example:

http://127.0.0.1:5000/employee/3e36267f-5a9c-4a02-9397-1f2fbee52ce1

Creating an employee:

Go to body, click on raw and choose JSON.

Doesn't work if you're not an admin.

http://127.0.0.1:5000/employee POST method

Example employee:

{"name": "john doe", "job_title": "doeing", "password": "123"}

Promoting an employee:

Doesn't work if you're not an admin.

http://127.0.0.1:5000/employee/(public_id) PUT method

Removing an employee:

Doesn't work if you're not an admin.

http://127.0.0.1:5000/employee/(public_id) DELETE method

Task lists

These are employee specific and not visible to admin users.

Checking tasks:

http://127.0.0.1:5000/job_tasks GET method

Creating a task:

Go to body, click on raw and choose JSON.

http://127.0.0.1:5000/job_tasks POST method

Example task:

{"task": "do things"}

With the given ID check only one task:

http://127.0.0.1:5000/job_tasks/1 GET method

Finishing a task:

http://127.0.0.1:5000/job_tasks/1 PUT method

Removing a task:

http://127.0.0.1:5000/job_tasks/1 DELETE method
You can’t perform that action at this time.