Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@get('/css/')
def css(filename):
return static_file(filename, root='static/css/')
@get('/skeletonize')
def skeletonize():
response = '''
<form method="post" action="/skeletonize">
Body ID: <input type="text" name="bodyId">
<input type="submit" value="Submit">
'''
response += "<select name="\"database\"">"
for name in sorted(dvidEnvMap):
response += "<option name="" value="\""">" + name + "</option>"
response += "</select>"
response += "</form>"
return response
@get('/suggestions')
@view('suggestions')
def suggestions():
if not sm.validate_session():
redirect('/')
username = request.get_cookie('login')
return {
'login': request.get_cookie('login'),
'articles': get_article_titles_by_login(username, get_drafts=True)
}
@bottle.get('/csv')
def get_csv():
""" Converts JSON file to CSV and sends it to web server """
log(bottle.request)
with open('data.json') as infile:
data = json.load(infile, object_pairs_hook=OrderedDict)
validate(data)
# Flatten JSON data
flat_data = []
for dct in data:
flat = OrderedDict()
for k in dct:
if isinstance(dct[k], OrderedDict):
for kk in dct[k]:
flat[str(k) + '/' + str(kk)] = dct[k][kk]
else:
flat[k] = dct[k]
@get('/datasets/')
@CaptureException
def get_dataset(did, library, pid=None):
"""Return the complete record for a dataset, including the schema and all
partitions."""
gr = library.get(did)
if not gr:
raise exc.NotFound("Failed to find dataset for {}".format(did))
# Construct the response
d = {'identity': gr.identity.dict, 'partitions': {}}
files = library.files.query.installed.ref(gr.identity.vid).all
# Get direct access to the cache that implements the remote, so
@get ('/allon')
def ssl_allon():
return allon()
@get('/account/css', skip=UserVerifiedPlugin)
def css():
response.content_type = 'text/css'
if request.user.is_authenticated:
return template('user_authenticated_css', username=request.user.user_name)
else:
return template('user_not_authenticated_css')
@get('/datasets')
def get_datasets(library):
"""Return all of the dataset identities, as a dict, indexed by id."""
from ..orm import Dataset
return {dsid.cache_key: {
'identity': dsid.dict,
'refs': {
'path': dsid.path,
'cache_key': dsid.cache_key
},
'urls': {
'partitions': "{}/datasets/{}".format(_host_port(library), dsid.vid),
'db': "{}/datasets/{}/db".format(_host_port(library), dsid.vid)
},
'schema': {
@get("/media/", no_i18n=True)
def get_file(filename):
media_dir = app._config['henet']['media_dir']
fullpath = os.path.join(media_dir, filename)
mimetype = guess_type(fullpath)[0]
return static_file(filename, root=media_dir,
mimetype=mimetype)