Browse Source

hacking upload + generation

main
cellarspoon 3 years ago
parent
commit
98e0a930cf
No known key found for this signature in database GPG Key ID: 3789458B3D0C410
  1. 2
      Makefile
  2. 5
      app.py
  3. 6
      templates/index.html

2
Makefile

@ -1,5 +1,5 @@
default: run default: run
run: run:
@mkdir -p metadatum generated && \ @mkdir -p metadatum static/generated && \
FLASK_ENV=development FLASK_APP=app flask run FLASK_ENV=development FLASK_APP=app flask run

5
app.py

@ -50,11 +50,12 @@ def upload():
metadata_fpath = os.path.join(CWD, "metadatum", filename) metadata_fpath = os.path.join(CWD, "metadatum", filename)
f.save(metadata_fpath) f.save(metadata_fpath)
pdf = os.path.join(CWD, "generated", "test.pdf") pdf = os.path.join(CWD, "static", "generated", "{}.pdf".format(filename))
metadata = "sqlite:///{}".format(os.path.join(CWD, "metadatum", filename)) metadata = "sqlite:///{}".format(os.path.join(CWD, "metadatum", filename))
make_cards( make_cards(
pdf, metadata, ["title", "timestamp", "comments", "authors"], ["tags"] pdf, metadata, ["title", "timestamp", "comments", "authors"], ["tags"]
) )
return render_template("index.html", upload_form=upload_form, pdf=pdf) pdf_url = url_for("static", filename="generated/{}.pdf".format(filename))
return render_template("index.html", upload_form=upload_form, pdf=pdf_url)
return render_template("index.html", upload_form=upload_form) return render_template("index.html", upload_form=upload_form)

6
templates/index.html

@ -41,9 +41,9 @@
</form> </form>
{% if pdf %} <object data="{{ pdf }}" type="application/pdf">
<p> FOOOO </p> <iframe src="{{ pdf }}"></iframe>
{% endif %} </object>
</body> </body>
</html> </html>

Loading…
Cancel
Save