Merge branch 'master' of gits-15.sys.kth.se:ELAB/ELAB-partsearch

master
Davide Bongiovanni 8 years ago
commit 9624a012c1

@ -1,9 +1,10 @@
import json
import re
import sqlalchemy
from sqlalchemy.sql import select
from sqlalchemy.sql import text
from flask import Flask
from flask import render_template
from flask import render_template, send_from_directory
app = Flask(__name__)
@ -49,6 +50,13 @@ def query(filter, query):
r.close()
return json.dumps(l)
@app.route('/parts/getfile/<filename>')
def getfile(filename):
if(re.match('^[\w-_]+\.pdf$', filename) == None):
return 'No injections pls.'
return send_from_directory('/srv/datasheets/', 'filename')
def connect(user, password, db, host='localhost', port=5432):
'''Returns a connection and a metadata object'''
# We connect with the help of the PostgreSQL URL

Loading…
Cancel
Save