FastAPI学习
-
保存前端上传的文件
参考:https://geek-docs.com/fastapi/fastapi-questions/205_fastapi_how_to_save_uploadfile_in_fastapi.html
参考:https://www.php.cn/faq/584389.html
参考:https://blog.csdn.net/xys430381_1/article/details/123890134 -
集成数据库
参考:https://blog.csdn.net/weixin_51407397/article/details/131152251
执行原生sql:https://blog.csdn.net/dangsh_/article/details/107158470
参考:https://blog.csdn.net/wtt234/article/details/121144424 -
用户验证
参考:https://blog.csdn.net/wisdom_lp/article/details/132069607
参考: https://www.cnblogs.com/puffer/p/16417064.html
参考:https://www.cnblogs.com/xiao-xue-di/p/15770937.html -
文件下载
参考:https://www.cnblogs.com/bitterteaer/p/17581746.html
参考:https://blog.csdn.net/weixin_44198965/article/details/121783870
# 后端 @router.get('/download_file/{table_name}') def download_cash(table_name=Path(), conn=pd_conn,current_user: Dict = Depends(get_current_user)): # 从数据库中读取数据 # df = pd.read_sql_table(table_name, conn) # 保存数据到本地 # df.to_excel(f'upload/{table_name}.xlsx', index=False) # 指定文件类型为excel headers = { 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', } headers={} # 返回文件 return FileResponse(f'upload/{table_name}.xlsx', headers=headers)
// 前端 // 相关依赖:axios,js-file-download const downloadFile = (table) => { console.log(table) // 下载文件 return axios.get('/download_file/' + table,{ responseType: 'blob', }); } const handleDownload = async (table) => { let res = await downloadFile(table) fileDownload(res, table + '.xlsx') }
-
流式输出
参考:https://blog.csdn.net/qq_33211006/article/details/130897348
参考:https://blog.csdn.net/wangsenling/article/details/130911465 -
导包问题 attempted relative import with no known parent package
参考:https://blog.csdn.net/qq_41767116/article/details/120408040
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人