How to use the docassemble.webapp.app_and_db.app.route function in docassemble

To help you get started, we’ve selected a few docassemble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/uploadedpagescreen//', methods=['GET'])
def serve_uploaded_pagescreen(number, page):
    number = re.sub(r'[^0-9]', '', str(number))
    page = re.sub(r'[^0-9]', '', str(page))
    file_info = get_info_from_file_number(number)
    if 'path' not in file_info:
        logmessage('no access to file number ' + str(number))
        abort(404)
    else:
    # block_size = 4096
    # status = '200 OK'
        filename = file_info['path'] + 'screen-' + str(page) + '.png'
        if os.path.isfile(filename):
            return(send_file(filename, mimetype='image/png'))
        else:
            logmessage('path ' + filename + ' is not a file')
            abort(404)
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/authorize/', methods=['POST', 'GET'])
def oauth_authorize(provider):
    if not current_user.is_anonymous:
        return redirect(url_for('index'))
    oauth = OAuthSignIn.get_provider(provider)
    return oauth.authorize()
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/playground', methods=['GET', 'POST'])
@login_required
@roles_required(['developer', 'admin'])
def playground_page():
    form = PlaygroundForm(request.form, current_user)
    the_file = request.args.get('file', '')
    if request.method == 'GET':
        is_new = request.args.get('new', False)
    else:
        is_new = False
    if is_new:
        the_file = ''
    playground = SavedFile(current_user.id, fix=True, section='playground')
    #path = os.path.join(UPLOAD_DIRECTORY, 'playground', str(current_user.id))
    #if not os.path.exists(path):
    #    os.makedirs(path)
    if request.method == 'POST':
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/user/google-sign-in')
def google_page():
    return render_template('flask_user/google_login.html', title="Sign in")
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/speakfile', methods=['GET'])
def speak_file():
    audio_file = None
    filename = session['i']
    key = session['uid']
    question = request.args.get('question', None)
    question_type = request.args.get('type', None)
    file_format = request.args.get('format', None)
    the_language = request.args.get('language', None)
    the_dialect = request.args.get('dialect', None)
    if file_format not in ['mp3', 'ogg'] or not (filename and key and question and question_type and file_format and the_language and the_dialect):
        logmessage("Could not serve speak file because invalid or missing data was provided: filename " + str(filename) + " and key " + str(key) + " and question number " + str(question) + " and question type " + str(question_type) + " and language " + str(the_language) + " and dialect " + str(the_dialect))
        abort(404)
    entry = SpeakList.query.filter_by(filename=filename, key=key, question=question, type=question_type, language=the_language, dialect=the_dialect).first()
    if not entry:
        logmessage("Could not serve speak file because no entry could be found in speaklist for filename " + str(filename) + " and key " + str(key) + " and question number " + str(question) + " and question type " + str(question_type) + " and language " + str(the_language) + " and dialect " + str(the_dialect))
        abort(404)
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/packagestatic//', methods=['GET'])
def package_static(package, filename):
    the_file = docassemble.base.util.package_data_filename(str(package) + ':data/static/' + str(filename))
    if the_file is None:
        abort(404)
    extension, mimetype = get_ext_and_mimetype(the_file)
    return(send_file(the_file, mimetype=str(mimetype)))
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/uploadsignature', methods=['POST'])
def upload_draw():
    post_data = request.form.copy()
    #sys.stderr.write("Got to upload_draw\n")
    if '_success' in post_data and post_data['_success'] and '_the_image' in post_data:
        theImage = base64.b64decode(re.search(r'base64,(.*)', post_data['_the_image']).group(1) + '==')
        #sys.stderr.write("Got theImage and it is " + str(len(theImage)) + " bytes long\n")
        with open('/tmp/testme.png', 'w') as ifile:
            ifile.write(theImage)
        #sys.stderr.write("Saved theImage\n")
    #sys.stderr.write("Done with upload_draw\n")
    return redirect(url_for('index'))
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/logfile/', methods=['GET'])
@login_required
@roles_required(['admin', 'developer'])
def logfile(filename):
    if LOGSERVER is None:
        the_file = os.path.join(LOG_DIRECTORY, filename)
        if not os.path.isfile(the_file):
            abort(404)
    else:
        h = httplib2.Http()
        resp, content = h.request("http://" + LOGSERVER + ':8080', "GET")
        the_file, headers = urllib.urlretrieve("http://" + LOGSERVER + ':8080/' + urllib.quote(filename))
    return(send_file(the_file, as_attachment=True, mimetype='text/plain', attachment_filename=filename, cache_timeout=0))
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/user/google-sign-in')
def google_page():
    return render_template('flask_user/google_login.html', title="Sign in")
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / server.py View on Github external
@app.route('/uploadedpage//', methods=['GET'])
def serve_uploaded_page(number, page):
    number = re.sub(r'[^0-9]', '', str(number))
    page = re.sub(r'[^0-9]', '', str(page))
    file_info = get_info_from_file_number(number)
    if 'path' not in file_info:
        abort(404)
    else:
    # file_info = get_info_from_file_reference(number)
    # block_size = 4096
    # status = '200 OK'
        filename = file_info['path'] + 'page-' + str(page) + '.png'
        if os.path.isfile(filename):
            return(send_file(filename, mimetype='image/png'))
        else:
            abort(404)