Commit d654330d authored by Hemang Kumar's avatar Hemang Kumar

coala_online: Add coala_online endpoint

parent 8192b825
default_app_config = (
from django.apps import AppConfig
class CoalaOnlineConfig(AppConfig):
name = 'coala_online'
verbose_name = 'API endpoint to run coala and coala-quickstart online'
description = 'The ``coala_online`` endpoint helps' \
'users to run coala-quickstart and coala on their code' \
'snippet or on a git repository.'
import json
import subprocess
from collections import defaultdict
from django.http import JsonResponse
from django.views.decorators.http import require_http_methods
from coala_online.config import COALA_ONLINE_IMAGE
def coala_online(request):
Spawns a docker container to run coala and coala-quickstart as specified.
Documentation on the running modes can be found here,
request = json.loads(request.body.decode('utf-8'))
req = defaultdict(lambda : None)
req['mode'] = request['mode']
req['file_content'] = request.get('file_data', None)
req['language'] = request.get('language', None)
req['url'] = request.get('url', None)
req['sections'] = request.get('sections', None)
req_str = json.dumps(req)
proc = subprocess.Popen(
['docker', 'run', '-i', '--rm',
'python3', '', req_str],
response = json.loads('utf-8'))
return JsonResponse(response, safe=False)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment