Commit Graph

17 Commits

Author SHA1 Message Date
Alan Orth 4e52d1bcc9
Add configurable requests cache directory
As I expected, on Google App Engine we can't write the cache file
to the current working directory. I modified csv-metadata-quality
CLI to check for the REQUESTS_CACHE_DIR environment variable so we
don't really have to do anything different other than setting the
variable.
2021-03-14 10:06:39 +02:00
Alan Orth e7dd8d1421
Add AGROVOC lookup support
This works locally, but I don't think it will work on App Engine
because csv-metadata-quality uses requests-cache and creates the
agrovoc-response-cache.sqlite file in the current working directory.
2021-03-13 23:49:24 +02:00
Alan Orth 6c3804d55b
Add support for skipping fields ("-x") 2021-03-13 23:34:11 +02:00
Alan Orth 122d9fd53c
Add support for experimental checks ("-e") 2021-03-13 23:01:11 +02:00
Alan Orth 198acdb1a7
Major refactor
Re-work upload and file processing so they are in the same Python
function. Now I will start exposing other command line options in
the form, like unsafe fixes, excluding fields, etc. Now I see tha
t it is easier to save the POSTed file and process it in the same
function so I don't have to pass around the other POSTed form val
ues as URL query parameters.

Now, as a result of changing the flow above, I also had to make a
change to the way I show the results page. Instead of processing
the file and returning the rendered results to the user directly,
I process the file, save the rendered results to /tmp, and return
a redirect to the user to the results page.
2021-03-13 22:11:26 +02:00
Alan Orth adc2d06094
main.py: Add note about using /tmp
I originally wanted to use an "uploads" directory or something, but
it seems we can only write to /tmp on Google App Engine. They really
want you to buy storage or database services! This is memory mapped
so it disappears when you re-deploy.
2021-03-13 22:09:17 +02:00
Alan Orth 8603ec4bca
main.py: Rework command line args
Turns out we only need to use sys.argv when we were trying to run
the csv-metadata-quality module directly in Python by importing it.
2021-03-13 12:52:22 +02:00
Alan Orth 0471820f3a
main.py: Actually use sys.argv
I set this but never actually passed it to the subprocess. Now I'm
wondering if I actually need it, or if that was just when I was tr-
ying to import the csv-metadata-quality module?
2021-03-13 12:49:01 +02:00
Alan Orth 69abc3d764
Add downloading of cleaned CSV file 2021-03-12 23:00:48 +02:00
Alan Orth 126bf74ea0
main.py: Remove comments 2021-03-12 21:28:24 +02:00
Alan Orth 4de4388b1e
Encode filenames to base64 and change URL to /result 2021-03-12 21:22:03 +02:00
Alan Orth e13d63bf6b
Major refactor
Refactor the templates to include a header, use csv-metadata-quality
in a subshell instead of trying to import and pass args to it (which
I actually managed to do, but then trying to capture the output was
an issue), and use ansi2html to prepare the CLI output as the HTML.
2021-03-12 19:14:49 +02:00
Alan Orth 0136d99046
Add route for processing the input file 2021-03-11 22:42:59 +02:00
Alan Orth 4f1d6fad38
main.py: Import csv_metadata_quality
Now I understand how I can use this, for example to print the vers-
ion of the CLI tool in the HTML template.
2021-03-11 20:29:43 +02:00
Alan Orth d204c23b93
main.py: Try to upload to /tmp
Creating and uploading to an "uploads" directory works locally, but
on Google App Engine I get an HTTP 500. Let's try uploading to /tmp.
2021-03-11 16:06:33 +02:00
Alan Orth 81b5206e97
Add simple HTML template with file upload
Code taken from the following blog posts:
  - https://pythonbasics.org/flask-upload-file
  - https://blog.miguelgrinberg.com/post/handling-file-uploads-with-flask
2021-03-11 15:55:58 +02:00
Alan Orth 2a5f612fe9
Add main.py
Following basic Flask on Google App Engine tutorial:

https://realpython.com/python-web-applications/#build-a-basic-python-web-application
2021-03-11 14:32:50 +02:00