本文整理匯總了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
示例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 ###
示例3: add_contact
# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import form [as 別名]
def add_contact():
data = request.form
username = data['username']
示例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,
})
示例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
})
示例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"
示例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"
)
示例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
})
示例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,
})
示例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
})
示例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
})
示例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
})
示例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
})
示例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
})
示例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