将HTML表单数据传递到Python scrip

2024-04-25 00:25:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我是前端开发的新手,现在正在做一个完整的项目。我需要运行一个使用用户提供的一些信息编写的python脚本。我想在同一页上发布脚本的结果(目前仅使用stdout打印到终端)。我该怎么办?以下是我目前拥有的HTML:

<form>
<div class="form-group"> <!-- Client Device IP -->
    <label for="client_device_ip" class="control-label">Client Device IP</label>
    <input type="text" class="form-control" id="client_device_ip" name="client_device_ip" placeholder="0.0.0.0">
</div>

<div class="form-group"> <!-- Client Device Username -->
    <label for="client_username" class="control-label">Client Device Username</label>
    <input type="text" class="form-control" id="client_username" name="client_username" placeholder="root">
</div>

<div class="form-group"> <!-- client_device_pw -->
    <label for="client_device_pw" class="control-label">Client Device Password</label>
    <input type="text" class="form-control" id="client_device_pw" name="client_device_pw" placeholder="*******">
</div> 

... 3 more forms, removed for length

<div class="form-group"> <!-- Start Button -->
    <button type="submit" class="btn btn-primary">Start Test</button>
</div>

我的python脚本在从终端执行时运行良好,但我需要的信息目前是硬编码的。我需要对HTML和python脚本进行哪些更改才能将表单信息拉入脚本的变量中


Tags: divform脚本client信息fordevicetype