I found a website that if you put the link of the discord html file url into as an argument, it renders the html file:
https://mahto.id/chat-exporter?url=https://cdn.discordapp.com/attachments/1057723577815801866/1063152479761604608/transcript-void-t4-hypicksell.html
I want to recreate this with flask, and i just keep getting 403: Forbitten error
Here is my current code:
@app.route('/chat-exporter', methods=['GET'])
def chat_exporter():
url = request.args.get('url')
if url:
headers = {'User-Agent': 'Mozilla/5.0'}
response = get(url, headers=headers)
if response.ok:
html = response.text
print(f'html: {html}') # debug
return render_template('render.html', html=html)
else:
return f"Error: {response.status_code} {response.reason}"
else:
return "Error: No URL provided"
My flask route
{% block head %}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename = 'css/chat_exporter.css') }}">
{% endblock %}
{% block body %}
{{html|safe}}
{% endblock %}
This is my html file