Skip to content

Commit

Permalink
make sure cvs for locations can be accessed via the api
Browse files Browse the repository at this point in the history
  • Loading branch information
sekiskylink committed Feb 10, 2017
1 parent 79d56f6 commit c74105b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.swp
web/local_settings.py
web/test/test_flow.py
web/static/downloads/
*.zip
*.csv
*xls
Expand Down
10 changes: 5 additions & 5 deletions web/app/controllers/api2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
from . import db
import web
from settings import config
import os
# from settings import config
# import os
from app.tools.utils import get_basic_auth_credentials, auth_user


Expand Down Expand Up @@ -58,11 +58,11 @@ def GET(self):
return json.dumps({'detail': 'Authentication failed!'})
y = db.query("COPY(SELECT * FROM locations) to '/tmp/llin.csv' with delimiter ',' csv header;")
if y:
static_directory = config.get('static_directory', '/var/www/llinpro/web/static')
os.popen("zip /tmp/llin.csv.zip /tmp/llin.csv; cp /tmp/llin.csv.zip %s" % static_directory)
# static_directory = config.get('static_directory', '/var/www/llinpro/web/static')
# os.popen("zip /tmp/llin.csv.zip /tmp/llin.csv; cp /tmp/llin.csv.zip %s" % static_directory)
web.header("Content-Type", "application/zip; charset=utf-8")
# web.header('Content-disposition', 'attachment; filename=%s.csv'%file_name)
web.seeother("/static/llin.csv.zip")
web.seeother("/static/downloads/llin.csv.zip")
else:
web.header("Content-Type", "application/json; charset=utf-8")
return json.dumps({'detail': 'CSV download service failed!'})

0 comments on commit c74105b

Please sign in to comment.