API Endpoints
Reference for all server endpoints.
Overview
The Express server (app.js) exposes the following endpoints:
| Endpoint | Method | Description |
|---|---|---|
/submit | POST | Submit code to Gradescope |
/starter/:filename | GET | Get starter code template |
/lti/launch | POST | Handle LTI 1.3 launch |
/auth/status | GET | Check authentication status |
POST /submit
Submit student code to Gradescope for grading.
Request
http
POST /submit
Content-Type: application/jsonBody:
json
{
"code": "print('Hello, World!')",
"email": "student@school.edu",
"stud_id": "900123456",
"asg_id": "6617143",
"file_name": "program.py"
}Parameters
| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | The Python code to submit |
email | string | No | Student email address |
stud_id | string | No | Student ID |
asg_id | string | Yes | Gradescope assignment ID |
file_name | string | No | Filename (default: program.py) |
Response
Success (200):
json
{
"success": true,
"message": "Submission successful",
"url": "https://www.gradescope.com/courses/1106756/assignments/6617143/submissions/123456"
}Error (400):
json
{
"success": false,
"error": "Missing required field: asg_id"
}Error (500):
json
{
"success": false,
"error": "Gradescope submission failed"
}GET /starter/:filename
Retrieve starter code template for an assignment.
Request
http
GET /starter/lab1_starter.pyResponse
Success (200):
json
{
"code": "# Lab 1 Starter Code\n\ndef calculate_total(items):\n pass"
}Not Found (404):
json
{
"error": "Starter file not found"
}POST /lti/launch
Handle LTI 1.3 launch from D2L Brightspace.
Request
This endpoint receives an LTI 1.3 launch request from D2L. The request contains:
- JWT token with student information
- Course and assignment context
- Custom parameters
Response
On successful validation, redirects to the code editor with context:
302 Redirect → /codemirror-demo.html?email=...&asg_id=...On failure:
json
{
"error": "Invalid LTI launch"
}GET /auth/status
Check if the current session has valid Gradescope credentials.
Request
http
GET /auth/statusResponse
Authenticated:
json
{
"authenticated": true,
"email": "student@school.edu"
}Not Authenticated:
json
{
"authenticated": false
}Static Files
The server also serves static files:
| Path | File |
|---|---|
/ | codemirror-demo.html |
/mockD2L.html | Mock D2L interface |
/login.html | Gradescope login page |
/styles/* | CSS files |
Error Handling
All endpoints return consistent error responses:
json
{
"success": false,
"error": "Error message here"
}HTTP Status Codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad request (missing/invalid parameters) |
| 401 | Unauthorized (no valid session) |
| 404 | Not found |
| 500 | Server error |
Rate Limiting
Currently, there is no rate limiting implemented. For production, consider adding:
javascript
const rateLimit = require('express-rate-limit');
const limiter = rateLimit({
windowMs: 60 * 1000, // 1 minute
max: 10 // 10 requests per minute
});
app.use('/submit', limiter);