當前位置: 首頁>>代碼示例>>Python>>正文


Python request.form方法代碼示例

本文整理匯總了Python中flask.request.form方法的典型用法代碼示例。如果您正苦於以下問題:Python request.form方法的具體用法?Python request.form怎麽用?Python request.form使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask.request的用法示例。


在下文中一共展示了request.form方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: upload

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def upload():
    f = request.files['file']
    assert f, "Where's my file?"

    filekey = request.form.get('filekey') or str(uuid.uuid1())
    assert RE_ALLOWED_FILEKEYS.match('filekey'), 'Unacceptable file key'

    permpath = getpath(filekey)

    content_range = (f.headers.get('Content-Range') or
                     request.headers.get('Content-Range'))

    if content_range:
        result, kwargs = handle_chunked(f, permpath, content_range)
    else:
        result, kwargs = handle_full(f, permpath)

    kwargs['filekey'] = filekey

    return jsonify(result=result, **kwargs)


# Flask endpoint 
開發者ID:toolforge,項目名稱:video2commons,代碼行數:25,代碼來源:upload.py

示例2: query

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def query(user, repo, query_name, subdir=None, spec_url=None, sha=None, content=None):
    """Execute SPARQL query for a specific grlc-generated API endpoint"""
    glogger.info("-----> Executing call name at /{}/{}/{}/{} on commit {}".format(user, repo, subdir, query_name, sha))
    glogger.debug("Request accept header: " + request.headers["Accept"])

    requestArgs = request.args
    acceptHeader = request.headers['Accept']
    requestUrl = request.url
    formData = request.form

    query_response, status, headers = utils.dispatch_query(user, repo, query_name, subdir, spec_url,
                                                           sha=sha, content=content, requestArgs=requestArgs,
                                                           acceptHeader=acceptHeader,
                                                           requestUrl=requestUrl, formData=formData)
    if isinstance(query_response, list):
        query_response = jsonify(query_response)

    return make_response(query_response, status, headers)

### Server routes ### 
開發者ID:CLARIAH,項目名稱:grlc,代碼行數:22,代碼來源:server.py

示例3: add_contact

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def add_contact():
    data = request.form
    username = data['username'] 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:5,代碼來源:server.py

示例4: create_conversation_db

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def create_conversation_db():
    conversation_db_path = get_conversation_db_path_for_users(request.form)
    print(conversations_dir)

    if not os.path.exists(conversation_db_path):
        with open(conversation_db_path, 'w') as f:
            pass
        conversation = Conversation(conversation_db_path)
        conversation.initialise_table()

    return jsonify({
        "success": True,
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:15,代碼來源:server.py

示例5: get_message_history

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def get_message_history():
    conversation_db_path = get_conversation_db_path_for_users(request.form)
    conversation = Conversation(conversation_db_path)

    history = conversation.get_history()

    return jsonify({
        "history": history
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:11,代碼來源:server.py

示例6: send_me_data

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def send_me_data():
    data = request.form
    for key, value in data.items():
        print("received", key, "with value", value)

    return "Thanks" 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:8,代碼來源:server.py

示例7: add_user

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def add_user():
    data = request.form
    username = data["username"]
    real_name = data["real_name"]

    database.add_user(username, real_name)

    return jsonify(
        "User Created"
    ) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:12,代碼來源:server.py

示例8: user_exists

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def user_exists():
    username = request.form.get("username")
    exists = database.user_exists(username)

    return jsonify({
        "exists": exists
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:9,代碼來源:server.py

示例9: create_conversation_db

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def create_conversation_db():
    conversation_db_path = get_conversation_db_path_for_users(request.form)

    if not os.path.exists(conversation_db_path):
        with open(conversation_db_path, 'w') as f:
            pass
        conversation = Conversation(conversation_db_path)
        conversation.initialise_table()

    return jsonify({
        "success": True,
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:14,代碼來源:server.py

示例10: send_message

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def send_message(username):
    data = request.form
    author = data["author"]
    message = data["message"]
    date_sent = arrow.now().timestamp

    conversation_db_path = get_conversation_db_path_for_users({"user_one": author, "user_two": username})
    conversation = Conversation(conversation_db_path)
    conversation.add_message(author, message, date_sent)

    return jsonify({
        "success": True
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:15,代碼來源:server.py

示例11: update_avatar

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def update_avatar(username):
    img_b64 = request.form.get("img_b64")
    database.update_avatar(username, img_b64)

    return jsonify({
        "success": True
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:9,代碼來源:server.py

示例12: get_new_messages

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def get_new_messages():
    data = request.form
    conversation_db_path = get_conversation_db_path_for_users(data)
    conversation_db = Conversation(conversation_db_path)

    timestamp = data["timestamp"]
    requester_username = data["user_one"]

    new_messages = conversation_db.get_new_messages(timestamp, requester_username)

    return jsonify({
        "messages": new_messages
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:15,代碼來源:server.py

示例13: add_friend

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def add_friend():
    data = request.form
    user_one = data['user_one']
    user_two = data['user_two']

    if database.user_exists(user_two) and database.user_exists(user_one):
        database.add_friend(user_one, user_two)
        success = True
    else:
        success = False

    return jsonify({
        "success": success
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:16,代碼來源:server.py

示例14: block_friend

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def block_friend():
    data = request.form
    user_one = data['user_one']
    user_two = data['user_two']

    database.block_friend(user_one, user_two)

    return jsonify({
        "success": True
    }) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:12,代碼來源:server.py

示例15: post_message

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def post_message():
    content = request.form['commandInput']
    if len(content) > 0:
        if content[0] == global_settings.cfg[C_MAIN_SETTINGS][P_CMD_TOKEN]:
            text = RemoteTextMessage(channel_id=global_settings.mumble_inst.users.myself['channel_id'],
                                     session=global_settings.mumble_inst.users.myself['session'],
                                     message=content,
                                     actor=global_settings.mumble_inst.users.myself['session'])
            global_settings.bot_service.message_received(text=text, remote_cmd=True)
            # print(text.message)
    return content 
開發者ID:DuckBoss,項目名稱:JJMumbleBot,代碼行數:13,代碼來源:web_helper.py


注:本文中的flask.request.form方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。