随笔分类 -  python

摘要:os.getcwd() python引入os,getcwd()是获取当前文件的目录 阅读全文
posted @ 2019-07-08 16:29 braveheart007 阅读(623) 评论(0) 推荐(0)
摘要:from flask import Flask, jsonify,render_templateapp = Flask(__name__) @app.route("/")def hello(): return jsonify({"username":"hello world! Zhang"}) @a 阅读全文
posted @ 2019-07-07 07:26 braveheart007 阅读(138) 评论(0) 推荐(0)
摘要:如果flask要用abort函数就必须引入abort; from flask import abort @app.route("/login",methods=["GET"]) def login(): if null: abort(403) //抛出403异常,也可以抛出其他类型的代码如500,这 阅读全文
posted @ 2019-07-07 00:05 braveheart007 阅读(213) 评论(0) 推荐(0)
摘要:# 从request里面取出客户端传过来的文件,# 在服务器端打开一个文件# 读request里面的文件内容# 将读取的文件内容写入服务器端打开的文件# 关闭服务器端文件@app.route('/upload',methods=['POST'])def upload(): file_obj = re 阅读全文
posted @ 2019-07-06 23:07 braveheart007 阅读(4187) 评论(0) 推荐(0)
摘要:返回静态网页就用apache nigx; 返回动态网页要用WSGI,当然用flask等web框架配合用,web框架的作用是路由分发; 阅读全文
posted @ 2019-07-06 13:59 braveheart007 阅读(145) 评论(0) 推荐(0)
摘要:RESTFUL API 视频地址:https://www.bilibili.com/video/av22964634?from=search&seid=7007330453806066473 引用地址:https://www.cnblogs.com/rgcLOVEyaya/p/RGC_LOVE_YA 阅读全文
posted @ 2019-07-02 16:51 braveheart007 阅读(722) 评论(0) 推荐(0)
摘要:败给了python的elif:是elif,elif,elif,而不是elseif:if 判断条件1: 执行语句1…… elif 判断条件2: 执行语句2…… elif 判断条件3: 执行语句3…… else: 执行语句4…… 阅读全文
posted @ 2019-07-01 16:47 braveheart007 阅读(210) 评论(0) 推荐(0)
摘要:一个视图函数可以对应多个修饰器: @app.route('/')@app.route('/index.html')def index(): return render_template('index.html') 备注: 服务器端APP需要使用路由地址,如何获得呢? @app.route('/pos 阅读全文
posted @ 2019-07-01 00:11 braveheart007 阅读(160) 评论(0) 推荐(0)
摘要:python文件命名不可以与包的名字相同,否则会导致包无法引用!切记! 阅读全文
posted @ 2019-06-29 00:24 braveheart007 阅读(210) 评论(0) 推荐(0)