回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>老实说,我不知道我应该问什么问题。也许有人可以编辑我的标题以便更具描述性</p>
<p>我有一个python flask应用程序,有时会返回:</p>
<p><code>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</code></p>
<p>这种情况何时发生是有规律的,但我不知道为什么会发生</p>
<p>我有一个主页,用户单击谷歌地图上的一个标记,然后单击一个超链接“查看天气预报”按钮,这会将他们带到天气预报页面:
<a href="https://i.stack.imgur.com/UsBU7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UsBU7.jpg" alt="enter image description here"/></a></p>
<p>在我的主python文件(相当于index.py)中,我为下一页创建路由,如下所示:</p>
<pre><code>@app.route("/weather_forecast/<climbing_area>/<city_id>/<lat>/<lon>/<weather_site>") #creates url using climbing area name, city id, lat, lon, and location of weather site
def weather_forecast(climbing_area, city_id, lat, lon, weather_site):
return render_template('weather_forecast.html',
climbing_area=climbing_area,
city_id=city_id,
daily_forecast=wf.format_daily_forecast(city_id),
extended_forecast=wf.format_extended_forecast(city_id),
historical_forecast=wf.get_historical_weather(lat, lon),
dates=wf.get_date_range(),
lat=lat,
lon=lon,
weather_site=weather_site,
sites=db.create_site_list_sqlite(),
api_key=os.environ.get('GOOGLE_MAPS_JS_API_KEY'),
image_url=wf.image_choice(lat, lon, city_id))
</code></pre>
<p>如你所见,地图上有许多标记,其中95%的标记做了正确的事情,点击后进入天气预报页面。但其中有一些没有。它们总是不起作用</p>
<p>每个天气预报站点的URL由此模板动态生成:</p>
<p><code>/weather_forecast/<climbing_area>/<city_id>/<lat>/<lon>/<weather_site></code></p>
<p>这些是从/主页路由返回的变量。我的第一个想法是:因为这些是从后端(SQLite)动态生成的变量,可能没有为这些特定站点返回数据,这会导致页面失败?但我已经为这些选定的几个站点验证了数据是可用的</p>
<p>此URL可用于:</p>
<pre><code>http://localhost:5000/weather_forecast/Humboldt%20County/5558953/41.03/-124.113/Arcata
</code></pre>
<p>此URL不起作用:</p>
<pre><code>http://localhost:5000/weather_forecast/Mount%20Yonah/Tallulah%20Gorge/4188197/34.637/-83.72200000000001/Clarkesville
</code></pre>
<p>我不希望有一个神奇的代码修复,但有人能建议我还可以寻找什么?或者在我的问题中包含哪些其他信息会有帮助</p>