Don*_*cha 3 python bottle python-2.7 openshift
我正在使用python创建一个基于Web的应用程序,用户输入搜索查询并返回数据.我用瓶子为此提供了web框架.然后使用Openshift在线发布.这是一个简单的帖子表格,然后在下一节中使用搜索条件:
@route('/')
def search():
return '''
<h1 align="center">Twitter Sentiment Analysis</h1>
<p align="center">Enter what you would like to search in the search box below</p>
<form action="/result" method="post" align="center">
Search: <input name="search" type="text" />
<input value="Search" type="submit" />
</form>
'''
@route('/result', method='POST')
def result():
search = request.forms.get('search')
return 'it worked'
Run Code Online (Sandbox Code Playgroud)
当使用瓶子并测试它时,它工作正常,但是当我尝试将其部署到OpenShift时,我得到一个名称错误,"全局变量'请求'未定义"在测试时它在部署到openshift之前只与瓶子完美配合,有谁知道为什么会这样?
您好像没有将请求或路由导入到命名空间:
from bottle import get, post, request # or route
@get('/login') # or @route('/login')
def login():
return '''
<form action="/login" method="post">
Username: <input name="username" type="text" />
...
'''
@post('/login') # or @route('/login', method='POST')
def do_login():
user = request.forms.get('username')
pass = request.forms.get('password')
...
Run Code Online (Sandbox Code Playgroud)