gpt4 book ai didi

python - 谷歌应用引擎: post a group of entities at one time

转载 作者:太空宇宙 更新时间:2023-11-03 19:09:55 25 4
gpt4 key购买 nike

我正在尝试使用表单收集一组数据,但我不知道如何使用 POST 从表单中获取数据。提前致谢。程序:

main.py

    from google.appengine.ext import db
import webapp2
import common

class Company(db.Model):
name: db.StringProperty()
image: db.BlobProperty()
url: db.URLProperty()

class MainPage(webapp2.RequestHandler):
def get(self):
common.render(self, 'main.html', {'range': range(10)})

def post(self):
# How to do the following?
for i in range(10):
company = Company()
company.name = self.request.get("name")
company.image = self.request.get("image")
company.url = self.request.get("url")
company.put()

app = webapp2.WSGIApplication([('/', MainPage)], debug=True)

main.html

    <form action="/"  method="post" enctype="multipart/form-data">
<table>
<tr><th></th><th>Company</th><th>Image</th><th>URL</th></tr>
{% for i in range %}
<tr>
<td>{{ forloop.counter }}: </td>
<td><input type="text" name="name" id="name" /></td>
<td><input type="file" name="image" id="image" /></td>
<td><input type="text" name="url" id="url" /></td>
</tr>
{% endfor %}
</table>
<input type="submit">
</form>

--唐

最佳答案

.getall(key) 应该为你做。

# All values for a key: ['a', 'b']
check_values = request.POST.getall('check')

Webapp2 Request Data

关于python - 谷歌应用引擎: post a group of entities at one time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13330769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com