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
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from flask import Flask, flash, redirect, render_template, request, url_for
|
from flask import Flask, flash, redirect, render_template, request, url_for
|
||||||
|
import urllib.request
|
||||||
from hocrtransformpdf import *
|
from hocrtransformpdf import *
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from flask_basicauth import BasicAuth
|
from flask_basicauth import BasicAuth
|
||||||
@ -31,9 +32,13 @@ def run_script():
|
|||||||
# download PDF from url
|
# download PDF from url
|
||||||
file = request.form['file']
|
file = request.form['file']
|
||||||
if file:
|
if file:
|
||||||
uploadfilepath=os.path.join(app.config['UPLOAD_FOLDER'], file)
|
response = urllib.request.urlopen(file)
|
||||||
file.save(uploadfilepath)
|
file = open("static/pdf/downloaded.pdf", 'wb')
|
||||||
return redirect(url_for('uploaded_file',file=file))
|
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']
|
# url = request.form['url']
|
||||||
#if not url:
|
#if not url:
|
||||||
# flash('Url is required!')
|
# flash('Url is required!')
|
||||||
@ -59,14 +64,13 @@ def run_script():
|
|||||||
# filename=filename))
|
# filename=filename))
|
||||||
|
|
||||||
|
|
||||||
hocr_result = pdftotree.parse(uploadfilepath)
|
hocr_result = pdftotree.parse("static/pdf/downloaded.pdf")
|
||||||
app.logger.info("test")
|
|
||||||
hocr = HocrTransform(hocr_filename=hocr_result, dpi=300)
|
hocr = HocrTransform(hocr_filename=hocr_result, dpi=300)
|
||||||
hocr.to_pdf(
|
hocr.to_pdf(
|
||||||
out_filename='static/pdf/output-2.pdf',
|
out_filename='static/pdf/output-2.pdf',
|
||||||
image_filename='static/images/blank.png',
|
image_filename='static/images/blank.png',
|
||||||
show_bounding_boxes=False,
|
show_bounding_boxes=False,
|
||||||
interword_spaces=False,
|
interword_spaces=False
|
||||||
)
|
)
|
||||||
|
|
||||||
#hocrfile='static/hocr/gynaikoktonia.hocr'
|
#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 %}
|
{% block content %}
|
||||||
|
|
||||||
<!-- <iframe src="https://pad.vvvvvvaria.org/wordmord.test" height="800" width="800"></iframe> -->
|
<!-- <iframe src="https://pad.vvvvvvaria.org/wordmord.test" height="800" width="800"></iframe> -->
|
||||||
<form method="post">
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
|
<form method="post">
|
||||||
<!-- <input type="text" id="my_field" value="" wrap="soft"> -->
|
<!-- <input type="text" id="my_field" value="" wrap="soft"> -->
|
||||||
<textarea name="file" id="my_field" wrap="soft" placeholder="Επικόλληση του συνδέσμου του PDF του Ποινικού Κώδικα που βρήκατε στο ηλεκτρονικό ταχυδρομείο σας ή στο ΔΙΑΒΑΣΕΜΕ.txt, εδώ.
|
<textarea name="file" id="my_field" wrap="soft" placeholder="Επικόλληση του συνδέσμου του PDF του Ποινικού Κώδικα που βρήκατε στο ηλεκτρονικό ταχυδρομείο σας ή στο ΔΙΑΒΑΣΕΜΕ.txt, εδώ.
|
||||||
"></textarea>
|
"></textarea>
|
||||||
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
|
|
||||||
<button id="button3" onclick="readme()">ΔΙΑΒΑΣΕΜΕ.txt</button>
|
<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="button2" onclick="copy()"> ΑΝΤΙΓΡΑΦΗ ΚΩΔΙΚΑ</button>
|
||||||
<button id="button1" onclick="transform()">ΜΕΤΑΛΛΑΓΜΕΝΟΣ ΚΩΔΙΚΑΣ</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>
|
<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>
|
</table>
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user