download pdf from url
This commit is contained in:
parent
f2a7a8d000
commit
65b8ffbe32
Binary file not shown.
Binary file not shown.
16
app.py
16
app.py
@ -5,6 +5,7 @@ import string
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from flask import Flask, flash, redirect, render_template, request, url_for
|
||||
import urllib.request
|
||||
from hocrtransformpdf import *
|
||||
from werkzeug.utils import secure_filename
|
||||
from flask_basicauth import BasicAuth
|
||||
@ -31,9 +32,13 @@ def run_script():
|
||||
# download PDF from url
|
||||
file = request.form['file']
|
||||
if file:
|
||||
uploadfilepath=os.path.join(app.config['UPLOAD_FOLDER'], file)
|
||||
file.save(uploadfilepath)
|
||||
return redirect(url_for('uploaded_file',file=file))
|
||||
response = urllib.request.urlopen(file)
|
||||
file = open("static/pdf/downloaded.pdf", 'wb')
|
||||
file.write(response.read())
|
||||
file.close()
|
||||
#uploadfilepath=os.path.join(app.config['UPLOAD_FOLDER'], file)
|
||||
#file.save(uploadfilepath)
|
||||
#return redirect(url_for('uploaded_file',file=file))
|
||||
# url = request.form['url']
|
||||
#if not url:
|
||||
# flash('Url is required!')
|
||||
@ -59,14 +64,13 @@ def run_script():
|
||||
# filename=filename))
|
||||
|
||||
|
||||
hocr_result = pdftotree.parse(uploadfilepath)
|
||||
app.logger.info("test")
|
||||
hocr_result = pdftotree.parse("static/pdf/downloaded.pdf")
|
||||
hocr = HocrTransform(hocr_filename=hocr_result, dpi=300)
|
||||
hocr.to_pdf(
|
||||
out_filename='static/pdf/output-2.pdf',
|
||||
image_filename='static/images/blank.png',
|
||||
show_bounding_boxes=False,
|
||||
interword_spaces=False,
|
||||
interword_spaces=False
|
||||
)
|
||||
|
||||
#hocrfile='static/hocr/gynaikoktonia.hocr'
|
||||
|
378
downloaded.pdf
Normal file
378
downloaded.pdf
Normal file
File diff suppressed because one or more lines are too long
@ -3,20 +3,21 @@
|
||||
{% block content %}
|
||||
|
||||
<!-- <iframe src="https://pad.vvvvvvaria.org/wordmord.test" height="800" width="800"></iframe> -->
|
||||
<form method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<form method="post">
|
||||
<!-- <input type="text" id="my_field" value="" wrap="soft"> -->
|
||||
<textarea name="file" id="my_field" wrap="soft" placeholder="Επικόλληση του συνδέσμου του PDF του Ποινικού Κώδικα που βρήκατε στο ηλεκτρονικό ταχυδρομείο σας ή στο ΔΙΑΒΑΣΕΜΕ.txt, εδώ.
|
||||
"></textarea>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
|
||||
<button id="button3" onclick="readme()">ΔΙΑΒΑΣΕΜΕ.txt</button>
|
||||
<button id="button5" type="submit" onclick="decode()">ΠΡΟΒΟΛΗ ΠΟΙΝΙΚΟΥ ΚΩΔΙΚΑ <img src="{{url_for('static', filename='images/closed.gif')}}"></button>
|
||||
<button id="button5" onclick="decode()">ΠΡΟΒΟΛΗ ΠΟΙΝΙΚΟΥ ΚΩΔΙΚΑ <img src="{{url_for('static', filename='images/closed.gif')}}"></button>
|
||||
<button id="button2" onclick="copy()"> ΑΝΤΙΓΡΑΦΗ ΚΩΔΙΚΑ</button>
|
||||
<button id="button1" onclick="transform()">ΜΕΤΑΛΛΑΓΜΕΝΟΣ ΚΩΔΙΚΑΣ</button>
|
||||
<button id="button4" onclick="window.open('{{url_for('static', filename='pdf/ΣΧΕΔΙΟ_ΜΕΤΑΛΛΑΓΜΕΝΟΥ_ΠΟΙΝΙΚΟΥ_ΚΩΔΙΚΑ_01.pdf')}}');">ΚΑΤΕΒΑΣΕ ΜΕΤΑΛΛΑΓΜΕΝΟ ΚΩΔΙΚΑ <img src="{{url_for('static', filename='images/open.gif')}}"> </button>
|
||||
@ -48,7 +49,7 @@
|
||||
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user