Added the getfile app route

master
assar 8 years ago
parent 40a267f4d1
commit 3b4df3dee1

@ -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