【发布时间】:2021-12-31 15:16:57
【问题描述】:
如何从 Html 输入标签中获取输入并在 python 文件中使用它而无需创建本地主机?我不需要保存输入,只需在 python 中运行即可。
【问题讨论】:
标签: python html css python-3.x input
如何从 Html 输入标签中获取输入并在 python 文件中使用它而无需创建本地主机?我不需要保存输入,只需在 python 中运行即可。
【问题讨论】:
标签: python html css python-3.x input
def create_post(request):
if request.method == 'POST':
post_text = request.POST.get('the_post')
response_data = {}
post = Post(text=post_text, author=request.user)
post.save()
response_data['result'] = 'Create post successful!'
response_data['postpk'] = post.pk
response_data['text'] = post.text
response_data['created'] = post.created.strftime('%B %d, %Y %I:%M %p')
response_data['author'] = post.author.username
return HttpResponse(
json.dumps(response_data),
content_type="application/json"
)
else:
return HttpResponse(
json.dumps({"nothing to see": "this isn't happening"}),
content_type="application/json"
)
【讨论】: