简体   繁体   English

在Django应用程序中包含python控制台以与数据集进行交互

[英]Include python console in Django application to interact with dataset

How can I include a Python terminal / console in a Django application that users can execute python code against? 我如何在Django应用程序中包含一个Python终端/控制台,用户可以对其执行python代码? For example, df.column_b * df.column_a if the example data is: 例如,如果示例数据为: df.column_b * df.column_a

column_a, column_b
1,        2
2,        4
3,        8

My use case is that it is easy for me to get data into my Django application. 我的用例是,我很容易将数据获取到Django应用程序中。 However, a common use case is for users to copy and paste the data into a spreadsheet and start doing some work / computation with the data. 但是,一个常见的用例是用户将数据复制并粘贴到电子表格中,然后开始对数据进行一些工作/计算。 It would be nice if they didn't have to leave the page and could just do the computations directly in Python. 如果他们不必离开页面就可以直接在Python中进行计算,那将是很好的。

An example website is LearnPython.org . 一个示例网站是LearnPython.org After inspecting the website a little bit, it looks like it uses CodeMirror.js . 在稍微检查一下网站之后,看起来它使用了CodeMirror.js I have taken a look at the CodeMirror docs and the div for LearnPython.org's Run button, but it is not clear to me how I'd take the leap from registering an onClick event to: 我看过CodeMirror文档和LearnPython.org的Run按钮的div ,但是我不清楚我如何从注册onClick事件跃升为:

  • Sending the code to the Django server 将代码发送到Django服务器
  • Executing the code 执行代码
  • Sending the results back 发回结果

Or could I do this all client side? 还是我可以在所有客户端这样做?

Any pointers in the right direction is greatly appreciated. 任何朝着正确方向的指针都将不胜感激。

Have you seen this project ? 你看过这个项目吗?

What is DataCamp Light, and how can I use it? 什么是DataCamp Light,如何使用?

In addition to an extensive course library, DataCamp also offers 'Open Courses' that any DataCamp user can create and take. 除了丰富的课程库之外,DataCamp还提供任何DataCamp用户都可以创建和参加的“开放课程”。 If you already have MOOC (Massive Open Online course) content you would like to publish using the DataCamp learning environment, you can get started here: https://www.datacamp.com/teach and see some examples here: https://www.datacamp.com/community/open-courses . 如果你已经有了MOOC(大规模开放在线课堂)的内容,你想使用DataCamp学习环境进行发布,你可以在这里开始: https://www.datacamp.com/teach ,看到这里的一些例子: https://开头www.datacamp.com/community/open-courses

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

相关问题 使用 javascript 与控制台程序交互 - interact with a console program using javascript JavaScript console.error 重定向到 Daphne Django 应用程序中的文件 - JavaScript console.error redirect to file in Daphne Django application 在 web 应用程序上与 javascript 交互的桌面应用程序/脚本 - desktop application / script to interact with javascript on web application 创建自定义“控制台”对象以与浏览器中的 Web 控制台交互以进行自定义调试器 - Creating a custom "console" object to interact with Web Console in browser for custom debugger 在 JavaScript 控制台中包含 jQuery - Include jQuery in the JavaScript Console 如何与JavaScript中的Python路由进行交互? - How to interact with Python routes in javascript? 在控制台中显示数据集中的文本 - Displaying text from dataset in console 如何制作控制台插件以与Facebook游戏或其他Flash应用程序进行交互 - How to make a Console plugin to interact with facebook games or other flash apps 调试控制台 REPL 未响应调试会话。 无法与之互动 - Debug Console REPL not responding to a debug session. Not able to interact with httplib(python)可以与页面及其javascript进行交互吗? - can httplib (python) interact with a page and its javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM