html jinja2.exceptions.templatesyntaxerror:预期令牌':' got'}'错误
我使用Pycharm通过烧瓶创建了本地服务器。但是我想创建一个动态链接,此链接将是指向其他网站的链接。当我想提供直接链接时,它会尝试在我自己的服务器上连接。但是我不想要这个,我想访问Spotify,YouTube等网站。经过一番研究,我找到了类似于下面代码的代码。但是我收到了一条错误消息。
错误消息
jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'
我的html代码在这里
<dd>
<a href = {{ url_for('go_outside_flask_variable', variable={{music_link}} ) }}>Link</a>
</dd>
我的python代码在这里
@app.route('/go_outside_flask/<variable>')
def go_outside_flask_method(variable):
redirect(variable, code=302)
注意:音乐链接就像“ open.spotify/scotify/tracks/****” *”
I created a local server via Flask using Pycharm. But I want to create a dynamic link and this link will be a link to other websites. When I want to give a direct link, it tries to connect on my own server. But I don't want this, I want to access websites such as spotify, youtube. After some research, I found a code similar to the code below. But I am getting an error message.
ERROR MESSAGE
jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'
MY HTML CODE IS HERE
<dd>
<a href = {{ url_for('go_outside_flask_variable', variable={{music_link}} ) }}>Link</a>
</dd>
MY PYTHON CODE IS HERE
@app.route('/go_outside_flask/<variable>')
def go_outside_flask_method(variable):
redirect(variable, code=302)
Note: Music link is like "open.spotify/tracks/*****"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是由于变量= {{music_link}}引起的,
您可以尝试执行此操作
html
python
输出
---编辑以适合需求---
,如果您只想重定向到此链接,请执行
html
python
It is caused due to the variable={{music_link}}
You could try doing this
Html
Python
Output
---Edit to fit the need---
Now if you want to only redirect to this link just do
HTML
Python