zoukankan      html  css  js  c++  java
  • Flask的基本操作知识

    https://study.163.com/course/courseLearn.htm?courseId=1005913008&from=study#/learn/video?lessonId=1053446514&courseId=1005913008

    学习了flask的基本知识,做下笔记

    首先创建项目后在编辑结构里勾选上单一实例和DEBUG。

     1 from flask import Flask, render_template, request, redirect
     2 
     3 app = Flask(__name__)
     4 
     5 
     6 @app.route('/')
     7 def hello_world():
     8     # 通过url传递参数
     9     wd = request.args.get('wd')
    10     age = request.args.get('age')
    11     print(wd)
    12     print(age)
    13     return '好好学习'+wd
    14 
    15 
    16 @app.route('/index', methods=['GET', 'POST'])
    17 def index():
    18     # 表单参数传递
    19     if request.method == 'GET':
    20         return render_template('index.html')
    21     else:
    22         tel = request.form.get('tel')
    23         pwd = request.form.get('pwd')
    24         print('tel:%s'%tel)
    25         print('pwd:%s'%pwd)
    26         # 重定向
    27         return redirect('/profile/')
    28 
    29 
    30 @app.route('/profile/')
    31 def profile():
    32     return "个人中心页面"
    33 
    34 
    35 if __name__ == '__main__':
    36     app.run()

    index的代码

    <body>
    <img src="{{ url_for('static',filename='ss.jpg') }}">  
    <h1>登录窗口界面</h1>
    <form action="" method="post">
        <input type="text" name="tel">
        <input type="password" name="pwd">
        <button>登录</button>
    </form>
    </body>
  • 相关阅读:
    jQuery 在 IE 上 clone checkbox 的問題。
    C/C++ typedef用法
    C++继承
    map常用操作
    C++ JsonCpp 使用(含源码下载)
    string常用操作
    C++虚函数
    STL容器迭代过程中删除元素技巧(转)
    关于IE下用HTTPS无法下载/打开文件(转)
    C++STL概览
  • 原文地址:https://www.cnblogs.com/weiwei2016/p/10167364.html
Copyright © 2011-2022 走看看