简体   繁体   English

如何从 HTML 输入触发 Python 脚本?

[英]How to trigger Python script from HTML input?

I'm struggling with one part of building a website.我正在努力构建网站的一部分。 I'm using Vue for the front end and Python for the backend.我在前端使用 Vue,在后端使用 Python。 These are the steps I need to take:这些是我需要采取的步骤:

  1. Take a text input in a HTML text box:在 HTML 文本框中输入文本:

     <div class="search-wrapper"> <input type="text" v-model="search" placeholder="Enter Stock Ticker"/> </div>
  2. Run a python script that uses that text to run a Tweepy API search:运行 python 脚本,该脚本使用该文本运行 Tweepy API 搜索:

     t = tweetObj.tweetObject({{ html input here }}) tweet_string = t.get_created_at()
  3. Do a bunch of sentiment analysis (which is already done)做一堆情绪分析(已经完成)
  4. Fill in a bunch of charts on a website (which I already have a template for)在网站上填写一堆图表(我已经有一个模板)

What I don't understand is whether or not I need to use Django or Flask for the Python IO.我不明白的是我是否需要使用 Django 或 Flask 用于 Python ZCF380BD92F1C43AB25BFF1 Is this necessary to take the inputs or can I get by with just simple HTTP request modules?这是否需要输入,或者我可以通过简单的 HTTP 请求模块来解决吗? I do understand running everything in one server, but the front end part is very new to me and I'm confused.我确实理解在一台服务器上运行所有东西,但前端部分对我来说很新,我很困惑。 Would appreciate some guidance on this.希望能对此提供一些指导。

Your question is more based on what your requirement is, so I will suggest you to identify your Requirement and the scope of Project .您的问题更多基于您的要求,所以我建议您确定您的Requirement 和 Project 的 scope You can use basic classification like this:您可以像这样使用基本分类:

  1. Simple Request module : For very small project with no future plan to launch to public.简单请求模块:适用于没有未来计划向公众发布的非常小的项目。 Planning to use it just for Class project or learning.计划将其仅用于 Class 项目或学习。

  2. Flask : It is a Framework, light-weight, highly flexible and modular. Flask :它是一个框架,轻量级,高度灵活和模块化。 Best to be used for any kind of project ranging from small to large.最好用于从小到大的任何类型的项目。 It's best to use it as Backend for Web Apps or Mobile App Backend.最好将其用作 Web 应用程序或移动应用程序后端的后端。

  3. Django : It is large Framework providing most of the things you might need to develop large to very large projects by default in itself. Django :它是一个大型框架,默认情况下提供开发大型到超大型项目可能需要的大部分内容。 It gives additional security, modularity.它提供了额外的安全性和模块化。 Use it only if planning to build an application with a large user base仅在计划构建具有大量用户群的应用程序时使用它

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

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