使用Flask从请求URL传递HTTP参数

时间:2018-01-10 06:29:22

标签: python rest flask http-parameters

以下是我用于Simple REST API的代码。它工作正常。 REST URL就像http://127.0.0.1:8080/sample/100 但我需要传递100作为像http://127.0.0.1:8080/sample?runtime=100这样的键值对。这可能或任何其他python库将提供帮助

st_info   This  member  specifies  the  symbol's   type   and   binding
             attributes:

             STT_NOTYPE  The symbol's type is not defined.

             STT_OBJECT  The symbol is associated with a data object.

             STT_FUNC    The symbol is associated with a function or other
                         executable code.

             STT_SECTION The symbol is associated with a section.   Symbol
                         table  entries  of  this type exist primarily for
                         relocation and normally have STB_LOCAL bindings.

             STT_FILE    By convention, the symbol's name gives  the  name
                         of  the  source  file  associated with the object
                         file.  A file symbol has STB_LOCAL bindings,  its
                         section  index  is  SHN_ABS,  and it precedes the
                         other STB_LOCAL symbols of the  file,  if  it  is
                         present.

             STT_LOPROC  This  value  up  to  and  including STT_HIPROC is
                         reserved for processor-specific semantics.

             STT_HIPROC  This value down to and  including  STT_LOPROC  is
                         reserved for processor-specific semantics.

             STB_LOCAL   Local  symbols are not visible outside the object
                         file containing their definition.  Local  symbols
                         of  the  same  name  may  exist in multiple files
                         without interfering with each other.

             STB_GLOBAL  Global symbols are visible to  all  object  files
                         being  combined.   One  file's  definition  of  a
                         global  symbol  will   satisfy   another   file's
                         undefined reference to the same symbol.

             STB_WEAK    Weak  symbols  resemble global symbols, but their
                         definitions have lower precedence.

             STB_LOPROC  This value up  to  and  including  STB_HIPROC  is
                         reserved for processor-specific semantics.

             STB_HIPROC  This  value  down  to and including STB_LOPROC is
                         reserved for processor-specific semantics.

                         There are macros for packing  and  unpacking  the
                         binding and type fields:

                         ELF32_ST_BIND(info)     or    ELF64_ST_BIND(info)
                         extract a binding from an st_info value.

                         ELF32_ST_TYPE(info) or ELF64_ST_TYPE(info)
                         extract a type from an st_info value.

                         ELF32_ST_INFO(bind, type) or  ELF64_ST_INFO(bind,
                         type)
                         convert  a  binding  and  a  type into an st_info
                         value.

1 个答案:

答案 0 :(得分:0)

查看"请求对象" Flask Quickstart文档的部分在这里: http://flask.pocoo.org/docs/0.12/quickstart/

  

要访问URL中提交的参数(?key = value),您可以使用args属性:

searchword = request.args.get('key', '')

确保在导入中包含此内容:

from flask import request