Issue
A while ago, I created some mini games with python. And now i'm working with html. I know how to link a css file to an html file. But I do not know how to link a python file to some words in an html file.
I have tried to directly href it to my python file like this:
<a href="Alien Invasion\Main\Alien Invasion.py">Play the Game</a>
This is what I've got so far
{% load static %}
<html>
<link rel="stylesheet" type="text/css" href="{% static 'webinfos/style.css' %}">
<ul>
<li><a>Home</a></li>
<li><a>Alien Invasion</a>
<ul>
<li><a>Explanation of Game</a></li>
<li><a>How to play</a></li>
<li><a>Origin</a></li>
<li><a>Play the Game</a></li>
</ul>
</li>
<li><a>Crossy Road</a>
<ul>
<li><a>Explanation of Game</a></li>
<li><a>How to play</a></li>
<li><a>Origin</a></li>
<li><a>Play the Game</a></li>
</ul>
</li>
<li><a>Classic Snake Game</a>
<ul>
<li><a>Tips&Tricks</a></li>
<li><a>Best Gameplays</a></li>
<li><a>Funny Moments</a></li>
<li><a>How to Play</a></li>
</ul>
</li>
<li><a>Other stuff</a></li>
</ul>
</html>
I expected it so that when I click on the words that are linked to the file, it runs the game. But instead, it shows:
Page not found (404)
Can someone help me with this?
Solution
It's impossible to run a python file in the browser in the way that you're doing it. If you really want to run scripts in a browser it's best to look up JavaScript.
Answered By - user17640833 Answer Checked By - Katrina (WPSolving Volunteer)