CSRF-Token Cookie 攻击问题-Django

问题描述 投票:0回答:1

在Django框架中,当它是POST请求时,如果修改Cookie CSRF令牌,则会抛出403错误。但是当它是 GET 请求时,我尝试修改 Cookie CSRF-token,它返回了 200 OK 状态代码。我还想验证 GET 请求的令牌。

我在表单模板中提到了 {% csrf_token %} ,但它无法处理 GET 请求的这个问题。 我在视图中尝试了@csrf_protect,但没有帮助。

django cookies csrf django-csrf csrf-token
1个回答
0
投票

将 pandas 导入为 pd

用户上传的Excel文件的文件路径

文件路径=“/mnt/data/sss.xlsx”

让我们从'Sheet1'读取数据

尝试: sheet1_data = pd.read_excel(file_path,sheet_name='Sheet1',skiprows=3) # 根据之前的检查跳过前 3 行

# Calculate the total brokerage as the starting point
total_brokerage = sheet1_data["Brokerage"].sum()

# Define the growth projection parameters
months = 12
growth_rate = 2
projection_values = [total_brokerage * (growth_rate ** i) for i in range(1, months + 1)]

# Prepare the data for the projection sheet
growth_projection_df = pd.DataFrame({
    "Month": list(range(1, months + 1)),
    "Projected Value": projection_values
})

# Path to save the updated Excel file
output_file_path = "/mnt/data/updated_growth_projection.xlsx"

# Write the projection data to a new Excel file
with pd.ExcelWriter(output_file_path) as writer:
    growth_projection_df.to_excel(writer, sheet_name="Growth Projection", index=False)
    sheet1_data.to_excel(writer, sheet_name="Sheet1 Data", index=False)

output_file_path

例外情况为 e: str(e)

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.