【发布时间】:2020-12-16 23:55:39
【问题描述】:
Flask 应用程序正在呈现我的 css 文件的以前版本(我已保存并进行了更改,但是当我检查页面时,显示的 css 文件是以前的版本)。也许以前版本的 css 文件不知何故卡在缓存中?我尝试重新启动浏览器,没有运气。
代码如下:
app.py 文件的一部分(我正在渲染 HTML 文件的部分):
from flask import Flask,render_template,url_for,request
from twilio.rest import Client
app = Flask(__name__, template_folder='templates')
app.static_folder = 'static'
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader as pdr
#import yahoo finance api fixer
import fix_yahoo_finance as fyf
from pandas_datareader import data as pdr
from datetime import datetime, timedelta
@app.route('/')
def home():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)
index.html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles.css') }}" />
</head>
<body>
<h1>Ticker Predictor</h1>
<h2>Using Machine Learning to Predict Tomorrow's Stock Prices</h2>
<br>
<h3>Simply enter a valid stock ticker below and hit the predict button to receive a text message of tomorrow's predicted opening price of that stock within around 10 minutes!</h3>
<!-- Main Input For Receiving Query to our ML -->
<form action="{{ url_for('predict')}}"method="post">
<input type="text" placeholder="Input Stock Ticker Here" required="required" />
<button type="submit">Predict</button>
</form>
{{ prediction_text }}
</body>
</html>
这是文件结构:
TickerPredictor
|--static/
|--styles.css
|--templates/
|--index.html
|--app.py
任何帮助将不胜感激!谢谢!
【问题讨论】:
-
请将 HTML 缩减为一个显示问题的小文件,然后发布。您的问题很可能出在您的 HTML 中。
-
@DaveW.Smith,我刚刚将整个 index.html 添加到描述中
-
我更新了描述以及新的更新...