コード例 #1
0
ファイル: vsearch4web.py プロジェクト: marcovnyc/penguin-code
def do_search() -> 'html':
    """Extract the posted data; perform the search; return results."""

    @copy_current_request_context
    def log_request(req: 'flask_request', res: str) -> None:
        """Log details of the web request and the results."""
        sleep(15)  # This makes log_request really slow...
        with UseDatabase(app.config['dbconfig']) as cursor:
            _SQL = """insert into log
                    (phrase, letters, ip, browser_string, results)
                    values
                    (%s, %s, %s, %s, %s)"""
            cursor.execute(_SQL, (req.form['phrase'],
                                req.form['letters'],
                                req.remote_addr,
                                req.user_agent.browser,
                                res, ))

    phrase = request.form['phrase']
    letters = request.form['letters']
    title = 'Here are your results:'
    results = str(search4letters(phrase, letters))
    try:
        t = Thread(target=log_request, args=(request, results))
        t.start()
    except Exception as err:
        print('***** Logging failed with this error:', str(err))
    return render_template('results.html',
                           the_title=title,
                           the_phrase=phrase,
                           the_letters=letters,
                           the_results=results,)
コード例 #2
0
def search4json() -> 'json':
    """Returns the results of a call to 'search4letters' as json."""
    phrase = request.form['phrase']
    letters = request.form['letters']
    results = str(search4letters(phrase, letters))
    return jsonify(the_phrase=phrase,
                   the_letters=letters,
                   the_result=results)
コード例 #3
0
ファイル: FlaskTest2.py プロジェクト: hoovajr/MyRepo
def do_search() -> 'html':
    phrase = request.form['phrase']
    letters = request.form['letters']

    title = 'Here are your results.'

    results = str(vsearch.search4letters(phrase, letters))
    
    return render_template('results.html', the_phrase=phrase, the_letters=letters, the_title=title, the_results=results,)
コード例 #4
0
def search4() -> 'html':
    """Returns the results of a call to 'search4letters' to the browser."""
    phrase = request.form['phrase']
    letters = request.form['letters']
    results = str(search4letters(phrase, letters))
    return render_template('results.html',
                           the_title='Here are your results!',
                           the_phrase=phrase,
                           the_letters=letters,
                           the_results=results)
コード例 #5
0
ファイル: vsearch4web.py プロジェクト: marcovnyc/penguin-code
def do_search() -> 'html':
    """Extract the posted data; perform the search; return results."""
    phrase = request.form['phrase']
    letters = request.form['letters']
    title = 'Here are your results:'
    results = str(search4letters(phrase, letters))
    log_request(request, results)
    return render_template('results.html',
                           the_title=title,
                           the_phrase=phrase,
                           the_letters=letters,
                           the_results=results,)
コード例 #6
0
def render_search_response(gen_json:bool=False) -> str:
    """Return either a JSON- or HTML-formatted search response."""
    phrase = request.form['phrase']
    letters = request.form['letters']
    results = str(search4letters(phrase, letters))
    if gen_json:
        return jsonify(the_phrase=phrase,
                       the_letters=letters,
                       the_results=results)
    return render_template('results.html',
                           the_title='Here are your results!',
                           the_phrase=phrase,
                           the_letters=letters,
                           the_results=results)
コード例 #7
0
def do_search() -> 'html':
    """Extract the posted data; perform the search; return results."""
    phrase = request.form['phrase']
    letters = request.form['letters']
    title = 'Here are your results:'
    results = str(search4letters(phrase, letters))
    try:
        log_request(request, results)
    except Exception as err:
        print('***** Logging failed with this error:', str(err))
    return render_template('results.html',
                           the_title=title,
                           the_phrase=phrase,
                           the_letters=letters,
                           the_results=results,)
コード例 #8
0
ファイル: thread_demo.py プロジェクト: Chiva-Zhao/pproject
def do_search() -> 'html':
    phrase = request.form['phrase']
    letters = request.form['letters']
    rst = str(search4letters(phrase, letters))

    @copy_current_request_context
    def log_request(req: 'flask_request', res: str) -> None:
        sleep(5)  # This makes log_request really slow...
        with UseDatabase(app.config['dbconfig']) as cursor:
            _SQL = """insert into log
            (phrase, letters, ip, browser_string, results)
            values
            (%s, %s, %s, %s, %s)"""
            cursor.execute(_SQL,
                           (req.form['phrase'], req.form['letters'], req.remote_addr, req.user_agent.browser, res))

    try:
        t = Thread(target=log_request, args=(request, rst))
        t.start()
    except Exception as exp:
        print('***** Logging failed with this error:', str(exp))
    return render_template('results.html', the_title='查询结果', the_phrase=phrase, the_letters=letters, the_results=rst)
コード例 #9
0
def do_search() -> str:
    # return 'Hello world from Flask'
    return str(search4letters('life', 'eiru,!'))
コード例 #10
0
def search4() -> str:
    """Returns the results of a call to 'search4letters' to the browser."""
    return str(search4letters('life, the universe, and everything', 'xyz'))
コード例 #11
0
ファイル: vsearch4web.py プロジェクト: ahmedrazi/flaskapp
def do_search() -> str:
    phrase= request.form['phrase']
    letters = request.form['letters']
    return str(search4letters('phrase','letters'))
コード例 #12
0
ファイル: vsearch4web.py プロジェクト: Chiva-Zhao/pproject
def do_search() -> 'html':
    phrase = request.form['phrase']
    letters = request.form['letters']
    rst = str(search4letters(phrase, letters))
    log_request(request, rst)
    return render_template('results.html', the_title='查询结果', the_phrase=phrase, the_letters=letters, the_results=rst)
コード例 #13
0
ファイル: vsearch4web.py プロジェクト: Chiva-Zhao/pproject
def do_search0() -> str:
    phrase = request.form['phrase']
    letters = request.form['letters']
    return str(search4letters(phrase, letters))
コード例 #14
0
ファイル: webapp1.py プロジェクト: brettcarpio/WebDev
def hello() -> str:
    found = vsearch.search4letters('life the universe and everything', 'abcdef')
    return 'Hello from my first webapp: ' + str(found)
コード例 #15
0
def do_search() -> str:
    return str(search4letters('life, the universe, and everything', 'eiru,!'))
コード例 #16
0
def do_search() -> str:
    #print("New function called")
    return str(search4letters('life, the universe, and everything', 'eiru!'))
コード例 #17
0
def do_search() -> str:
    return str(search4letters('life, the universe, and everything', 'eiru,!'))
コード例 #18
0
def do_search() ->str:
    phrase = request.form['phrase']
    letters = request.form['letters']

    return str(search4letters(phrase, letters))
コード例 #19
0
def do_search() -> str:
    return str(search4letters("life, the universe, and everything", "eiru"))