我的代码在插入值后拉出一个空白页

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

我在 Bubble 中运行代码并且输入值页面工作正常但是当我点击应该使用方法“发布”的提交按钮以使用第二个 html 文件显示结果时页面只是空白。运行我的代码的网站是 http://sambilli.pythonanywhere.com/final 所以如果使用它会有所帮助。 (下面的代码,每个部分下面都有文件名。)(请注意,我目前正在处理底部的 if 语句,并且只完成了 (character == 1) 和 (character == 2)


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Genshin Calculator</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        background-color: #f2f2f2;
      }
  
      h1 {
        text-align: center;
        color: #333;
      }

      form {
        max-width: 400px;
        margin: 0 auto;
        background-color: #fff;
        padding: 20px;
        border-radius: 5px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.3);
      }
 
      label {
        display: block;
        margin-bottom: 10px;
      }
  
      select {
        width: 100%;
        padding: 10px;
        border-radius: 5px;
        border: none;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        box-sizing: border-box;
      }

      button[type="submit"] {
        display: block;
        margin-top: 20px;
        background-color: #333;
        color: #fff;
        border: none;
        border-radius: 5px;
        padding: 10px;
        font-size: 16px;
        cursor: pointer;
      }

      button[type="submit"]:hover {
        background-color: #555;
      }
    </style>
  </head>
  <body>
    <h1>Genshin Impact Calculator</h1>
    <form action="/damage_results" method="post">
      <fieldset>
        <label>Character:</label>
        <select name="character">
          <option value="0">Hu tao(Pyro)</option>
          <option value="1" selected>Xiangling(Pyro)</option>
          <option value="2">Xiao(Anemo)</option>
          <option value="3">Raiden Shogun(Electro)</option>
        </select>

        <label>Weapon:</label>
        <select name="weapon">
          <option value="0" selected>Catch</option>
          <option value="1">Staff of Homa</option>
          <option value="2">Deathmatch</option>
          <option value="3">Staff of Scarlet Sands</option>
        </select>

        <label>Reactions(Pyro Characters Only):</label>
        <select name="reaction">
          <option value="0" selected>None</option>
          <option value="1">Vaporize</option>
          <option value="2">Melt</option>
        </select>
      </fieldset>

      <button type="submit">Submit</button>
    </form>
  </body> 
</html>

^indexfinal.html


<%
from bottle import request

character = request.forms.get("character")
character = int(character)

weapon = request.forms.get("weapon")
weapon = int(weapon)

reaction = request.forms.get("reaction")
reaction = int(reaction)

weaponBaseAttack = (454.36, 509.61, 564.78, 620.03, 541.83, 608.07, 674.33, 740.58)
#arrays of each different weapon types that contain the possible weapon options
weaponList = ("catch", "homa", "deathmatch", "soss")
#set of arrays that has each characters base stats
characterNames = ("hu tao", "xiangling", "xiao", "raiden")
characterBA = (106.43, 225.14, 349.2, 337.24)
characterHP = (15552, 10875, 12736, 12907)
characterDEF = (876.15, 668.87, 799.30, 789.31)
characterEM = (0, 96, 0, 0)
characterCR = (.05, .05, .242, .05)
characterCD = (.884, .50, .50, .50)
characterER = (0, 0, 0, .32)
characterBD = (0, 0, 0, 0)

if(reaction == 1):
    reactionDMGbonus = 1.5 * (1 + (2.78 * EM)/(1400 + EM))
elif(reaction == 2):
    reactionDMGbonus = 2 * (1 + (2.78 * EM)/(1400 + EM))
else:
    reactionDMGbonus = 1

BA = characterBA[character]
HP = characterHP[character]
DEF = characterDEF[character]
EM = characterEM[character]
CR = characterCR[character]
CD = characterCD[character]
ER = characterER[character]
atkP = 0
atkP = float(atkP)
ATK = 311
ATK = float(ATK)
bonusDMG = float(characterBD[character]) + 1
#Converts all characters base values to floats (part of setBaseStats)
BA = float(BA)
HP = float(HP)
DEF = float(DEF)
ER = float(ER)
EM = float(EM)
CR = float(CR)
CD = float(CD)
ER = float(ER)

if(weapon == 0):
    #catch
    ER = ER + .459
    BA = BA + weaponBaseAttack[1]
    CR = CR + .311
elif(weapon == 1):
    #homa
    CD = CD + .662
    BA = BA + weaponBaseAttack[5]
    CR = CR + .311
    maxHP = (HP * .20) + HP + 4780
    if(character != 0):
        ATK = (.018 * maxHP) + ATK
elif(weapon == 2):
    #deathmatch
    CR = CR + .368
    BA = BA + weaponBaseAttack[0]
    CD = CD + .662
    atkP = atkP = .32
elif(weapon == 3):
    #soss
    CR = CR + .441
    BA = BA + weaponBaseAttack[4]
    CD = CD + .662
    ATK = (.52 * EM)

if(character == 1):
    #xiangling
    baseEnemyResistance = .1
    baseEnemyResistance = float(baseEnemyResistance)
    atkP = atkP + 46.6
    ATK = ATK + BA * (1 + atkP)
    ATK = float(ATK)
    enemyResistance = 1 - baseEnemyResistance
    formulaDMG = ATK * bonusDMG * (CR * CD + 1) * .5 * enemyResistance
    DMG = 2.016 * formulaDMG * reactionDMGbonus
elif(character == 0):
    #hutao
    baseEnemyResistance = .1
    baseEnemyResistance = float(baseEnemyResistance)
    formulaDMG = ATK * bonusDMG * (CR * CD + 1) * .5 * enemyResistance
elif(character == 2):
    #xiao
    atkP = atkP + 46.6
    ATK = ATK + BA * (1 + atkP)
    ATK = float(ATK)
    baseEnemyResistance = .1
    baseEnemyResistance = float(baseEnemyResistance)
    enemyResistance = 1 - baseEnemyResistance
    bonusDMG = bonusDMG + .952 + .466 + .15
    formulaDMG = ATK * bonusDMG * (CR * CD + 1) * .5 * enemyResistance
    DMG = 4.04 * formulaDMG
elif(character == 3):
    #raiden
    atkP = atkP + 46.6
    ATK = ATK + BA * (1 + atkP)
    ATK = float(ATK)
    baseEnemyResistance = .1
    baseEnemyResistance = float(baseEnemyResistance)
    enemyResistance = 1 - baseEnemyResistance
    formulaDMG = ATK * bonusDMG * (CR * CD + 1) * .5 * enemyResistance


end
%>

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Genshin Calculator - Results</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f2f2f2;
    }

    h1 {
      text-align: center;
      color: #333;
    }

    p {
      margin-bottom: 10px;
      font-size: 16px;
      color: #555;
    }
  </style>
</head>
<body>
  <h1>Genshin Impact Calculator - Results</h1>
  <p>Your High Plunge Damage is {{DMG}}.</p>
</body>
</html>

^resultsfinal.html


from bottle import default_app, route, post, template

@route('/form')
def index():
    return template('index.html')

@post('/result')
def calculate_bmi():
    return template('calculate_bmi.html')

@route('/formbb')
def indexbb():
    return template('indexbb.html')

@post('/resultbb')
def calculate_bmibb():
    return template('calculate_bmibb.html')

@route('/final')
def indexfinal():
    return template('indexfinal.html')

@post('/damage_results')
def resultsfinal():
    return template('resultsfinal.html')

application = default_app()

^bottle_app.py

感谢您的帮助,我希望程序启动并运行。

我从字面上期待任何东西出现在页面上至少有一个标题。但似乎该程序甚至没有使用我的 html 代码。

python html css forms bottle
© www.soinside.com 2019 - 2024. All rights reserved.