【问题标题】:HTML form to python serverHTML表单到python服务器
【发布时间】:2019-05-06 03:59:07
【问题描述】:

我有 python 服务器,上面运行着烧瓶

from flask import Flask,render_template

app = Flask(__name__)

@app.route("/")

def main():
    return render_template('index.html')

if __name__  == ("__main__"):
    app.run(debug = True, host = "0.0.0.0", port =80)

这是 index.html 有简单的表单和发送按钮

    <!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>whatl0ol</title>




  <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">



</head>

<body>

  <div class="login">
  <div class="heading">
    <h2></h2>
    <form action="#">

      <div class="input-group input-group-lg">
        <span class="input-group-addon"><i class="fa fa-user"></i></span>
        <input type="text" class="form-control" placeholder="">
          </div>



        <button type="submit" class="float">check</button>
       </form>
        </div>
 </div>



</body>

</html>

当用户从索引页面发送时,我需要解决方案,将其从 python 发送到 API。

还需要有关网站带宽的建议。

谢谢

【问题讨论】:

  • 我不知道为什么我得到 - -es
  • 你在使用任何框架吗?或者只是自定义 python 确保您对 web-server 可读的 css 文件夹具有正确的权限?
  • im 使用 python 烧瓶服务器路由到 /
  • 使用 chmod -R 777

标签: python html api server


【解决方案1】:

确保您在此路径中有 css 文件

/your-project/static/css/style.css

还可以更改模板中的 css 以从静态文件夹加载它

<link href="{{ url_for('static', filename='css/style.css') }}" />

【讨论】:

  • @whatlOol 您在下面的评论中说下一个答案有模板文件夹,其中您有“css/style.css”,请将其移动到 /root/static/
  • @whatlOol 我刚刚尝试点击178.128.203.72/static/css/style.css,它根据我的回答向我显示css,如果你做得正确,这应该可以工作。
猜你喜欢
  • 2019-02-19
  • 1970-01-01
  • 1970-01-01
  • 2011-09-28
  • 2015-12-07
  • 2018-12-14
  • 2022-12-12
  • 2018-05-24
  • 1970-01-01
相关资源
最近更新 更多