上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 181 下一页
摘要: 一,docker官网文档 https://docs.docker.com/engine/install/ubuntu/ 参考上面官方的安装文档 二,安装docker 更新软件包索引并安装软件包以允许使用 基于 HTTPS 的存储库 # apt update # apt install ca-cert 阅读全文
posted @ 2025-11-14 23:04 刘宏缔的架构森林 阅读(38) 评论(0) 推荐(0)
摘要: 编辑neon的源 # vi /etc/apt/sources.list.d/neon.list 内容:// 注释原有内容,新增下面一行 sudo vi /etc/apt/sources.list.d/neon.list deb https://mirrors.bfsu.edu.cn/kde-neon 阅读全文
posted @ 2025-11-14 22:55 刘宏缔的架构森林 阅读(72) 评论(0) 推荐(0)
摘要: 一,代码: 自定义异常: class ApiError(Exception): """"API接口异常错误""" messsage = "" # 默认错误码 status_code = 400 # 自定义一个return_code, 作为更细粒的错误代码 def __init__(self, mes 阅读全文
posted @ 2025-11-14 20:27 刘宏缔的架构森林 阅读(11) 评论(0) 推荐(0)
摘要: 一,代码: 异常 处理: # 异常处理 @app.errorhandler(Exception) def handle_exception(error): stack = traceback.format_exc() app.logger.error(f"An error occurred: {st 阅读全文
posted @ 2025-11-14 19:45 刘宏缔的架构森林 阅读(5) 评论(0) 推荐(0)
摘要: 一,代码: python from flask import Flask, stream_with_context, Response import time photo = Blueprint('photo', __name__) @photo.route('/stream') def strea 阅读全文
posted @ 2025-11-13 18:19 刘宏缔的架构森林 阅读(12) 评论(0) 推荐(0)
摘要: 一,安装第三方库 $ pip install flask-cors 二,代码: from flask_cors import CORS app = Flask(__name__) # 解决存在跨域的问题 CORS(app) 阅读全文
posted @ 2025-11-12 18:35 刘宏缔的架构森林 阅读(16) 评论(0) 推荐(0)
摘要: 一,安装第三方库 auth $ pip install flask-httpauth jwt $ pip install Authlib 二,代码: from flask import Blueprint,jsonify,render_template,request from flask impo 阅读全文
posted @ 2025-11-11 23:18 刘宏缔的架构森林 阅读(16) 评论(0) 推荐(0)
摘要: 一,使用HTTPBasicAuth的方式发送用户名密码 发送账号和密码的方式有很多,这里我们用HTTPBasicAuth的方式,HTTPBasicAuth规定了发送账号密码必须要把账号和密码放到HTTP的header里面。header是一组一组key:value的键值对。key=Authorizat 阅读全文
posted @ 2025-11-11 21:59 刘宏缔的架构森林 阅读(17) 评论(0) 推荐(0)
摘要: 一,有哪些钩子函数? 1、app.before_request:在每次请求之前运行2、app.after_request:如果没有未处理的异常抛出,在每次请求后运行(视图函数正常退出)3、app.teardown_request:每次请求后运行,即使有未处理的异常抛出 二,例子: 代码: @app. 阅读全文
posted @ 2025-11-11 14:37 刘宏缔的架构森林 阅读(6) 评论(0) 推荐(0)
摘要: 一,用途 1. g是什么g相当于单次请求中的“全局变量”,能在单词请求中调用,但是和其他请求是互相隔离的 2. 生命周期请求过来创建,请求结束销毁;仅适用于单次请求,g的生命周期即一个请求的生命周期注:和session不同,session是多个请求都可以使用的 3. g能做什么可以在单次请求中定义一 阅读全文
posted @ 2025-11-11 14:23 刘宏缔的架构森林 阅读(24) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 181 下一页