如何從 Html 輸入標簽獲取輸入并在 python 檔案中使用它而無需創建本地主機?我不需要保存輸入,只需在 python 中運行它。
uj5u.com熱心網友回復:
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"
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/399323.html
