feat: Handle empty URL case

This commit is contained in:
Cristian 2020-07-01 12:29:56 -05:00
parent c971e00c9c
commit 364c5752d8
2 changed files with 218 additions and 235 deletions

View file

@ -57,19 +57,22 @@ class AddLinks(View):
def post(self, request):
url = request.POST['url']
print(f'[+] Adding URL: {url}')
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())
if url:
print(f'[+] Adding URL: {url}')
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())
}
context = {
"stdout": ansi_to_html(add_stdout.getvalue())
}
else:
context = {"stdout": "Please enter a URL"}
return render(template_name=self.template, request=request, context=context)