Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在web.py的基本模板中的表单上使用POST方法?_Python_Forms_Post_Web.py - Fatal编程技术网

Python 如何在web.py的基本模板中的表单上使用POST方法?

Python 如何在web.py的基本模板中的表单上使用POST方法?,python,forms,post,web.py,Python,Forms,Post,Web.py,正如标题所说,我想在我的网站上做一个搜索栏。但是我不想在所有的类上重复POST函数,我希望有一个更简单的方法。搜索栏位于我的基本模板上 这是我的基本模板中的表格: <form class="navbar-form navbar-right" method="POST" role="search"> <div class="form-group"> <div class="input-group"> <

正如标题所说,我想在我的网站上做一个搜索栏。但是我不想在所有的类上重复POST函数,我希望有一个更简单的方法。搜索栏位于我的基本模板上

这是我的基本模板中的表格:

<form class="navbar-form navbar-right" method="POST" role="search">
     <div class="form-group">
         <div class="input-group">
             <input class="form-control" id="navbarInput-01" type="search" name="search" placeholder="Search">
             <span class="input-group-btn">
                 <button type="submit" class="btn"><span class="fui-search"></span></button>
            </span>
         </div>
     </div>               
</form>

我只为我的主页制作了一个POST方法,但我希望我的所有页面都有它。我有很多课程,复制/粘贴这些内容会很乏味。

你能给我们看一些代码吗?让我们看看你现在是如何发布的。编辑了我的原始帖子
import web
from bin import Categories, Search
from web import form

render = web.template.render('templates/', base='layout')

db = web.database(dbn="sqlite", db="webDB")

urls = (
    '/', 'home',
    '/about', 'about',
    '/contact', 'contact',
    '/blog', 'blog',
    '/faqs', 'faqs',
    '/tos', 'tos',
    '/cat', Categories.app_cat,
    '/search', Search.app_search
)

class home:
    def GET(self):
        return render.home()

    def POST(self):
        data = web.input()
        search = data.search
        raise web.seeother('/search/'+search)