Skip to content

Commit

Permalink
Add static assets
Browse files Browse the repository at this point in the history
  • Loading branch information
kristallizer committed May 30, 2014
1 parent 46f6cb6 commit b194b0a
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
*~
10 changes: 10 additions & 0 deletions api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from getenv import env
import drest

class MetpetAPI():
def __init__(self, user, api):
self.username = user
self.api_key = api
self.api = drest.api.TastyPieAPI('{0}/api/v1/'.format(env('API_HOST')))
if self.username:
self.api.auth(user, api)
53 changes: 52 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
from flask import Flask
import ast
import urllib
import json
from flask import Flask, request, render_template, url_for
import dotenv
import drest

from api import MetpetAPI
from utilities import paginate_model


app = Flask(__name__)

@app.route('/')
def index():
return render_template('index.html')

@app.route('/samples')
def samples():
api = MetpetAPI(None, None).api

filters = ast.literal_eval(json.dumps(request.args))
offset = request.args.get('offset', 0)
filters['offset'] = offset
data = api.sample.get(params=filters)

next, previous, last, total_count = paginate_model('samples', data, filters)

samples = data.data['objects']
for sample in samples:
mineral_names = [mineral['name'] for mineral in sample['minerals']]
sample['mineral_list'] = (', ').join(mineral_names)

first_page_filters = filters
del first_page_filters['offset']

if filters:
first_page_url = url_for('samples') + '?' + urllib.urlencode(first_page_filters)
else:
first_page_url = url_for('samples') + urllib.urlencode(first_page_filters)

return render_template('samples.html',
samples=samples,
next_url=next,
prev_url=previous,
total=total_count,
first_page=first_page_url,
last_page=last)



if __name__ == '__main__':
dotenv.read_dotenv('../app_variables.env')
app.run(debug=True)
Binary file added static/images/MPDBlogo_sml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/lightbox-blank.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/lightbox-btn-close.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/lightbox-btn-next.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/lightbox-btn-prev.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/lightbox-ico-loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/mpdb.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/mpdb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/prev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b194b0a

Please sign in to comment.