博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Flask的基本操作知识
阅读量:6864 次
发布时间:2019-06-26

本文共 1063 字,大约阅读时间需要 3 分钟。

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 '好好学习'+wd14 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的代码

  

登录窗口界面

 

转载于:https://www.cnblogs.com/weiwei2016/p/10167364.html

你可能感兴趣的文章