avciTheProgrammer/automotive-compiler
0
C Compiler API
Public API for compiling and running C code using GCC, Clang, or PC-Lint (Splint).
๐ Public Endpoints
Base URL: Replace with your actual space URL
GET /
Get API information and available endpoints
Example:
curl https://YOUR-USERNAME-SPACE-NAME.hf.space/GET /health
Health check endpoint
Example:
curl https://YOUR-USERNAME-SPACE-NAME.hf.space/healthPOST /compile
Compile and execute C code
Request Body:
{
"code": "#include <stdio.h>\nint main() {\n printf(\"Hello World\\n\");\n return 0;\n}",
"filename": "main.c",
"compiler": "gcc"
}Response:
{
"success": true,
"output": "",
"errors": "",
"executable_output": "Hello World\n"
}Example with curl:
curl -X POST https://YOUR-USERNAME-SPACE-NAME.hf.space/compile \
-H "Content-Type: application/json" \
-d '{
"code": "#include <stdio.h>\nint main() { printf(\"Hello\\n\"); return 0; }",
"compiler": "gcc"
}'Example with JavaScript:
const response = await fetch('https://YOUR-USERNAME-SPACE-NAME.hf.space/compile', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code: '#include <stdio.h>\nint main() { printf("Hello\\n"); return 0; }',
compiler: 'gcc'
})
});
const result = await response.json();
console.log(result);๐ง Supported Compilers
gcc- GNU C Compilerclang- Clang C Compilerpclint- PC-Lint (uses Splint as open-source alternative)
๐ API Documentation
Interactive API docs available at:
- Swagger UI:
/docs - ReDoc:
/redoc
โ๏ธ Features
- โ Compile C code with multiple compilers
- โ Execute compiled programs safely
- โ Get compilation errors and warnings
- โ Capture program output
- โ CORS enabled for web applications
- โ Automatic timeout protection
๐ Security
- Code execution is sandboxed in temporary directories
- 10-second compilation timeout
- 5-second execution timeout
- Automatic cleanup of temporary files
- No persistent storage
๐ Notes
- This API is public and free to use
- Rate limits may apply based on Hugging Face Spaces limits
- For PC-Lint, this uses Splint (open-source alternative) as PC-Lint is proprietary
