Skip to content

4DERT/Tutor-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tutor app server

Enpoints

/ or /announcements

GET, POST methods

GET method returns all announcments

You can filter announcements by adding GET parameters like:

?subject=matematyka

You can add multiple filters joing them using '&':

?subject=informatyka&price_from=10

All avaible filters:

  • price_from
  • price_to
  • subject
  • degree_course
  • semester
  • is_negotiable
  • date_posted_from
  • date_posted_to

Date format is: YYYY-mm-dd

You can also sort by price or date using:

?price_sort=asc
?date_sort=desc

POST method

{
  "title": "Ucze jak robić równania różniczkowe",
  "content": "fajny opis",
  "price": 120,
  "is_negotiable": false,
  "degree_course": "informatyka",
  "subject": "matematyka",
  "semester": 4
}

Only users with prz collage email can add announcements!

/announcements/id

GET, PUT, DELETE methods

You can edit announcement using PUT method (the same json as in announcements)

/sign_up

POST method

{
    "username": "pijoter",
    "email": "pjoter12@demo.com",
    "password": "qwerty",
    "name": "Piotr",
    "surname": "Kowalski"
}

/login

POST method

user can be either an email or username

{
    "user": "pjoter12@demo.com",
    "password": "qwerty"
}

/logout

GET method

/my_account

GET, PUT, DELETE method

Returns logged user info.

To edit account use PUT method with following json:

{
    "description": "Fajny. młody, ciekawy a co najważniejsze przystojny chłopak",
    "email": "4DERT@demo.com",
    "name": "Jarosław",
    "phone": "213742071",
    "surname": "Jarząbkowski",
    "semester": 4,
    "degree_course": "informatyka"
}

degree_course, semester and phone can NULL. Make sure phone is an string value and semester is INT from 1 to 7.

/my_account/password

PUT method

Allows to change passowrd

{
    "old_password": "qwerty",
    "new_password": "password"
}

/my_account/avatar

GET, PUT, DELETE methods

This endpoint returns base64 encoded image (png or jpg) To send avatar use PUT method (couse default is NULL) and use form-data with key named 'file'. Avatar must be either PNG or JPEG, max size 512 x 512 px

/user/username

GET method

Returns info about given user

/user/username/review

POST, PUT, DELETE methods

{
  "rate": 5,
  "review": "Fajny korepetytor"
}

/user/username/avatar

GET methods Returns base64 encoded image (png or jpg)

/subjects

GET, POST method

Returns all subjects

POST - this methods are only available for admin

To add subject use POST method with following JSON:

{
  "subject" : "matematyka",
  "degree_course" : "informatyka",
  "semester" : 1
}

/subjects/degree_course/semester/subject

GET, PUT, DELETE methods

GET - returns more detailed subject data

PUT, DELETE - this methods are only available for admin, PUT uses the same JSON as subjects

/degree_courses

GET, POST method

Returns all degree_courses

To add degree courses use POST with following JOSN:

{
  "degree_course": "informatyka"
}

This method is only available for admin

/degree_courses/degree_course

GET, PUT, DELETE method

GET - returns more detailed degree course data

PUT, DELETE - this methods are only available for admin, PUT uses the same JSON as degree_courses

Application settings

You can configure an app secret key and admin usernames in .env file:

SECRET_KEY="KEY"
ADMINS=4DERT,pablo
PORT=8080
IS_DEBUG=True
DATABASE_URI="sqlite:///db.sqlite3"

To do

  • user sesions and log in
  • password hash
  • announcements filtering
  • loged user info endpoint
  • other users info endpoint
  • find better validation system, try...catch is bleh
  • find way to store user avatars in the db
  • announcements sorting
  • add ratings and reviews about users
  • store SECRET_KEY in .env
  • announcements editing
  • announcements deleting
  • reviews editing
  • reviews deleting
  • account editing
  • account deleting
  • subjects editing
  • subjects deleting
  • degree course editing
  • degree course deleting
  • add endpoint to change password
  • and more... ?

About

Python backend server for collage project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •