当前位置:网站首页>flask项目跨域拦截处理以及dbm数据库学习【包头文创网站开发】
flask项目跨域拦截处理以及dbm数据库学习【包头文创网站开发】
2022-04-23 08:04:00 【上进小菜猪】
文章目录
作者简介: 大家好,我是上进小菜猪。内蒙古科技大学,大二计科。技术很菜但不放弃,努力做全栈。 热爱开发,开发软件,开发网站,开发各种东西。️
️个人主页: 上进小菜猪的博客
系列专栏:本文写在网站开发专栏 ️如果文章知识点有错误的地方,请指正! 和大家一起学习一起进步
如果觉得博主的文章还不错的话,请三连+关注支持一下博主哦
一,前言
今天可以说是划水的一天,做的东西不是很多,今天主攻了,之前没结束的包头项目,最近想着尽快结束这个项目,但是一连遇到俩大难题,时间都花在改bug上了。
二,dbm数据库问题
这是老问题了。终极原因还是Linux系统下的架构与window系统不适配的原因,看了好久,因为代码量及其的大,看不懂的东西也是及其的多,改了好久和对dbm的菜鸟级了解,才勉强实现了改这个bug。
问题发现:
属性配置失灵,人傻了当时。这个是非常重要的功能,我转换完dbm数据库发现这个功能不能使用,而且,我在服务器上恢复初始版本也还是不能使用这个功能,我怀疑之前这个功能存在问题。
问题解决:
经过我对dbm的了解与学习【现在依然是菜鸟了解水平】因为我还不能使用python完全的遍历出来,网上的教程及其的少。没有参考可以看!
import dbm
上文代码解释:
引入dbm模块。
with dbm.open('config', 'c') as db:
print('keys():', db.keys())
打开我们的名为config的dbm数据库,这个数据库非常的奇怪,奇怪到我从来没有见过这种数据库。
我们已可都可写的方式打开他。
我们先输出一下数据库里面的key值
keys(): [b'btn_2', b'past_matchs', b'pw_nums', b'btn_3', b'btn_1', b'upload', b'btn_4', b'time', b'match', b'time_3_posts', b'btn_5', b'time_2_posts', b'match_name']
如上所示,我们拿到了这个数据库的所有key值,我们观察这些规律,猜测他们的代码意思与作用【接手别人的项目太困难了】
for k in db.keys():
print(k, db[k])
我尝试用数学建模的方式清洗他们。
哈哈,有点懵。
我继续研究他们,发现是格式问题,我尝试转换他们,在尝试了一些方法之后。
str(db[k],'utf-8')
行,哈哈挺简单。
b'past_matchs' ,2021|包头市第二界文化旅游创意作品大赛
b'pw_nums' 3
b'upload' false
b'time' 2
b'match' 2021
b'time_3_posts'
b'time_2_posts' 200
Process finished with exit code 0
观察这些文字:2021|包头市第二界文化旅游创意作品大赛。
大赛成绩,上传作品,往期回顾,评委入口,包头市第二界文化旅游创意作品大赛。
又到了你猜我画环节了,我基本知道里面的意义,但是,这个遍历是不完整的,没有完全的遍历出来,归根结底是我对dbm数据库的格式不清楚。
不完整,我明天要继续肝这个问题,深入的学习一下,现在遍历出这些东西,够我找之前的属性配置失灵bug。
db_config=dbm.open('config','c')
我尝试使用我自己写的dbm来替代他。
我们来尝试一下功能。
到路由层里,弄一下添加操作。
db_config["past_matchs"] = db_config["past_matchs"].decode(
)+f",{value}|{request.form.get('match_name')}"
测试,基本完成,但是bug有点大,遍历现在也不完整,明天继续研究,继续搞一下。
三,项目跨域拦截处理
这个bug,怎么说,够坑人的,我看了俩天,最后解决了这个bug。
但是让我接触到了json的跨域拦截与跨域问题,初步接触,虽然大部分研究都不在真确的方向上,但是基本学习了一下。
是这么一回事:
现在我需要添加一个作品,然后报错了。跨域问题,存储图片被拒绝了。
然后我就以falsk框架的问题来研究。
想是js跨域问题解决
from flask_cors import CORS
app = Flask(__name__)
CORS(app, supports_credentials=True)
方法用了个遍,啥用没有。
问题解决:
因为之前的服务器被挖矿了,换了个服务器,ip变了、
跨域访问的cors设置还是只允许之前的ip访问oss。
我添加了一条新规则,问题解决了。
。。。搞了俩天竟然是因为ip规则的问题。
不过初步接触到了跨域问题。
版权声明
本文为[上进小菜猪]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_52908342/article/details/124357224
边栏推荐
- Ansible Automation Operation and Maintenance details (ⅰ) Installation and Deployment, Parameter use, list Management, Profile Parameters and user level ansible operating environment Construction
- Trust uses Tokio's notify and timeout to achieve the effect similar to the timeout condition variable
- 关于ORB——SLAM运行中关键帧位置越来越近的异常说明
- 数据可视化:使用Excel制作雷达图
- 耳穴减肥自身感受细节描述0422
- redis主从服务器问题
- Green apple film and television system source code film and television aggregation film and television navigation film and television on demand website source code
- JS converts tree structure data into one-dimensional array data
- Navicat remote connection MySQL
- 跨域配置报错: When allowCredentials is true, allowedOrigins cannot contain the special value “*“
猜你喜欢
Vowel substring in statistical string of leetcode simple problem
Transformer XL: attention language modelsbbeyond a fixed length context paper summary
通过实现参数解析器HandlerMethodArgumentResolver接口来自定义注解
synchronized 实现原理
QT compilation qtxlsx Library
freertos学习02-队列 stream buffer message buffer
Excle plus watermark
PgSQL wants to implement all kinds of column sub query operations of MySQL
Search the complete navigation program source code
跨域配置报错: When allowCredentials is true, allowedOrigins cannot contain the special value “*“
随机推荐
Generate and parse tokens using JWT
Qtablewidget header customization and beautification developed by pyqt5 (with source code download)
Large amount of data submitted by form post
QFileDialog 选择多个文件或文件夹
There are some problems when using numeric type to query string type fields in MySQL
Enctype attribute in form
DOM learning notes - traverse all element nodes of the page
Green apple film and television system source code film and television aggregation film and television navigation film and television on demand website source code
dmp引擎工作总结(2021,光剑)
【解释】get ORA-12838: cannot read/modify an object after modifying it in parallel
耳穴诊疗随笔0421
[explanation] get ora-12838: cannot read / modify an object after modifying it in parallel
How to generate assembly file
Common regular expressions
什么是RPC
Qt读写XML文件
Add listening event to input element
Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
使用JWT生成与解析Token
An example of network communication based on TCP / IP protocol -- file transmission