Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -447,6 +447,41 @@ custom_html = """
|
|
447 |
}
|
448 |
});
|
449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
</script>
|
451 |
</body>
|
452 |
</html>
|
@@ -506,6 +541,13 @@ if __name__ == "__main__":
|
|
506 |
except Exception as e:
|
507 |
return {'error': str(e)}
|
508 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
# Define Gradio interface
|
510 |
demo = gr.Blocks()
|
511 |
with demo:
|
@@ -529,5 +571,11 @@ if __name__ == "__main__":
|
|
529 |
lambda: gr.update(value=extract_info(url_textbox.value))
|
530 |
)
|
531 |
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
# Launch Gradio interface
|
533 |
demo.launch()
|
|
|
447 |
}
|
448 |
});
|
449 |
|
450 |
+
const submitButton = document.createElement('button');
|
451 |
+
submitButton.textContent = 'Submit';
|
452 |
+
submitButton.classList.add('btn', 'btn-primary');
|
453 |
+
submitButton.addEventListener('click', async () => {
|
454 |
+
const token = githubTokenInput.value;
|
455 |
+
const repoUrl = repoUrlInput.value;
|
456 |
+
const issueNumber = issueDropdown.value;
|
457 |
+
const resolution = resolutionTextarea.value;
|
458 |
+
const forkedRepoUrl = forkedRepoUrlInput.value;
|
459 |
+
if (!token || !repoUrl || !issueNumber || !resolution) {
|
460 |
+
outputTextarea.value ="Please provide all required fields.";
|
461 |
+
return;
|
462 |
+
}
|
463 |
+
try {
|
464 |
+
const response = await fetch('/submit', {
|
465 |
+
method: 'POST',
|
466 |
+
headers: {
|
467 |
+
'Content-Type': 'application/json',
|
468 |
+
},
|
469 |
+
body: JSON.stringify({ token: token, repoUrl: repoUrl, issueNumber: issueNumber, resolution: resolution, forkedRepoUrl: forkedRepoUrl }),
|
470 |
+
});
|
471 |
+
if (!response.ok) {
|
472 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
473 |
+
}
|
474 |
+
const data = await response.json();
|
475 |
+
if (data.error) {
|
476 |
+
outputTextarea.value = data.error;
|
477 |
+
} else {
|
478 |
+
outputTextarea.value = data.result;
|
479 |
+
}
|
480 |
+
} catch (error) {
|
481 |
+
outputTextarea.value = `Error submitting issue: ${error.message}`;
|
482 |
+
}
|
483 |
+
});
|
484 |
+
document.body.appendChild(submitButton);
|
485 |
</script>
|
486 |
</body>
|
487 |
</html>
|
|
|
541 |
except Exception as e:
|
542 |
return {'error': str(e)}
|
543 |
|
544 |
+
def submit_issue(github_token, repo_url, issue_number, resolution, forked_repo_url):
|
545 |
+
try:
|
546 |
+
result = handle_issue_selection(github_token, repo_url.split('/')[-2], repo_url.split('/')[-1], issue_number, resolution, forked_repo_url)
|
547 |
+
return {'result': result}
|
548 |
+
except Exception as e:
|
549 |
+
return {'error': str(e)}
|
550 |
+
|
551 |
# Define Gradio interface
|
552 |
demo = gr.Blocks()
|
553 |
with demo:
|
|
|
571 |
lambda: gr.update(value=extract_info(url_textbox.value))
|
572 |
)
|
573 |
|
574 |
+
# Submit issue endpoint
|
575 |
+
submit_button = gr.Button("Submit")
|
576 |
+
submit_button.click(
|
577 |
+
lambda: gr.update(value=submit_issue(github_token_input.value, repo_url_input.value, issue_dropdown.value, resolution_textarea.value, forked_repo_url_input.value))
|
578 |
+
)
|
579 |
+
|
580 |
# Launch Gradio interface
|
581 |
demo.launch()
|