我正在尝试在flask中提供静态index.html,以及一些javascript代码,但我得到的是404或
ValueError: Unable to infer MIME-type because no filename is available. Please set either `attachment_filename`, pass a filepath to `filename_or_fp` or set your own MIME-type via `mimetype`.
在调试控制台中。
我认为最重要的代码片段是那些:
app = Flask(__name__,static_url_path='/static')
@app.route('/' ,methods=['GET'])
def home():
return app.send_static_file('index.html')
@app.route('/static/<path:path>', methods=['GET'])
def staticReturn(path):
return app.send_static_file(path)
我为我提供了index.html,但没有我引用index.html的文件。我指的是我的文件:
<link rel="stylesheet" type="text/css" href="static/bootstrap.css">