-
Notifications
You must be signed in to change notification settings - Fork 0
Home
rkz edited this page Apr 9, 2013
·
5 revisions
- The
electifs_coremodule contains all the business logic and is independant from the web interface concerns. -
electifs.pyis the main entry point to the web application (it implements the HTTP server-side logic). Responses are JSON for the REST API, or generated from the templates in thetemplatesdirectory. - Files in the
staticdirectory are served as is to the HTTP client.
From the server point of view, the web application is composed of a single page exposed at URL /.
Most of the server interaction is controlled via a REST API which exposes routes starting by /api/ and which always return JSON responses.
-
/api/ratings: GET the ratings for a specific course (in admin mode, will return all the ratings; otherwise, only the ratings which have been validated and accepted) -
/api/post-rating: POST a rating to a course -
/api/admin/loginand/api/admin/logoutto switch the admin mode on or off
The JSON responses always follow the same format:
{
"status": "success|error",
["error": {
"code": "error_code",
"message": "Error description in full text",
[additional error information]
},]
[additional response data]
}
On success, the HTTP status code is always 200. On error, it is never 200:
- 404 (not found) if the URL (before the parameters part) references a resource that cannot be found
- 400 (bad request) if some GET/POST paremeter is missing or has a wrong syntax
- 412 (precondition failed) if a parameter's value blocks the request
Examples:
/api/get-ratings throws HTTP 404
/api/ratings or /api/ratings?course_id=AAA throw HTTP 400
/api/ratings?course_id=99 throws 412 if no course with ID 99 exists