简体   繁体   English

如何使用python从浏览器获取用户输入

[英]How I can get user input from browser using python

I am in the middle of my personal website development and I am using python to create a "Comment section" which my visitors could leave comments at there in public (which means, everybody can see it, so don't worry about the user name registration things). 我正在个人网站开发过程中,正在使用python创建一个“评论部分”,我的访问者可以在此处在公共场所发表评论(这意味着每个人都可以看到它,因此不必担心用户名注册的东西)。 I already set up the sql database to store those data but only thing I haven't figured out yet was how to get the user input (their comments) from the browser. 我已经设置了sql数据库来存储这些数据,但是我还没有弄清楚的是如何从浏览器获取用户输入(他们的评论)。 So, is there any modules in python could do that? 那么,python中是否有任何模块可以做到这一点? (Like, the "Charfield" things in django, but unfortunately I don't use django) (就像django中的“ Charfield”一样,但是不幸的是我不使用django)

For that you would need a web framework like Bottle or Flask. 为此,您将需要一个诸如Bottle或Flask之类的Web框架。 Bottle is a simple WSGI based web framework for Python. Bottle是一个简单的基于WSGI的Python Web框架。

Using either of these you may write simple REST based APIs, one for set and other for get. 使用这两种方法之一,您都可以编写基于REST的简单API,一个用于set,另一个用于get。 The "set" one could accept data from your client side and store it on your database where as your "get" api should return the data by reading it from your DB. “设置”可以接受来自客户端的数据,并将其存储在数据库中,因为“获取” api应该通过从数据库读取数据来返回数据。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM