mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-27 13:14:24 -04:00
feat: Add stdout from process to the template
This commit is contained in:
parent
bc1f925542
commit
c971e00c9c
4 changed files with 276 additions and 208 deletions
|
@ -8,6 +8,9 @@ from django.conf import settings
|
|||
|
||||
from core.models import Snapshot
|
||||
|
||||
from contextlib import redirect_stdout
|
||||
from io import StringIO
|
||||
|
||||
from ..index import load_main_index, load_main_index_meta
|
||||
from ..config import (
|
||||
OUTPUT_DIR,
|
||||
|
@ -16,7 +19,7 @@ from ..config import (
|
|||
PUBLIC_INDEX,
|
||||
PUBLIC_SNAPSHOTS,
|
||||
)
|
||||
from ..util import base_url
|
||||
from ..util import base_url, ansi_to_html
|
||||
from .. main import add
|
||||
|
||||
|
||||
|
@ -55,12 +58,20 @@ class AddLinks(View):
|
|||
def post(self, request):
|
||||
url = request.POST['url']
|
||||
print(f'[+] Adding URL: {url}')
|
||||
add(
|
||||
import_str=url,
|
||||
update_all=False,
|
||||
out_dir=OUTPUT_DIR,
|
||||
)
|
||||
return redirect('/')
|
||||
add_stdout = StringIO()
|
||||
with redirect_stdout(add_stdout):
|
||||
extracted_links = add(
|
||||
import_str=url,
|
||||
update_all=False,
|
||||
out_dir=OUTPUT_DIR,
|
||||
)
|
||||
print(add_stdout.getvalue())
|
||||
|
||||
context = {
|
||||
"stdout": ansi_to_html(add_stdout.getvalue())
|
||||
}
|
||||
|
||||
return render(template_name=self.template, request=request, context=context)
|
||||
|
||||
|
||||
class LinkDetails(View):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue