How do you run a python file in html





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-2















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 InvasionMainAlien 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&amp;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?
Thanks.










share|improve this question


















  • 1





    In Django you don't link the Python file, you link the route defined for your view.

    – Klaus D.
    Jan 3 at 2:58











  • But how will a Python game run in the browser?

    – xyres
    Jan 3 at 3:20











  • Either use Pygame directly or use projects like Titanium or skulpt. But you can not make a web game in python. You have to use js or simply create it with C++ or Java.

    – Bidhan Majhi
    Jan 3 at 6:59


















-2















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 InvasionMainAlien 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&amp;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?
Thanks.










share|improve this question


















  • 1





    In Django you don't link the Python file, you link the route defined for your view.

    – Klaus D.
    Jan 3 at 2:58











  • But how will a Python game run in the browser?

    – xyres
    Jan 3 at 3:20











  • Either use Pygame directly or use projects like Titanium or skulpt. But you can not make a web game in python. You have to use js or simply create it with C++ or Java.

    – Bidhan Majhi
    Jan 3 at 6:59














-2












-2








-2


1






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 InvasionMainAlien 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&amp;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?
Thanks.










share|improve this question














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 InvasionMainAlien 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&amp;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?
Thanks.







python html django virtualenv






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 2:53









Newton YuanNewton Yuan

13




13








  • 1





    In Django you don't link the Python file, you link the route defined for your view.

    – Klaus D.
    Jan 3 at 2:58











  • But how will a Python game run in the browser?

    – xyres
    Jan 3 at 3:20











  • Either use Pygame directly or use projects like Titanium or skulpt. But you can not make a web game in python. You have to use js or simply create it with C++ or Java.

    – Bidhan Majhi
    Jan 3 at 6:59














  • 1





    In Django you don't link the Python file, you link the route defined for your view.

    – Klaus D.
    Jan 3 at 2:58











  • But how will a Python game run in the browser?

    – xyres
    Jan 3 at 3:20











  • Either use Pygame directly or use projects like Titanium or skulpt. But you can not make a web game in python. You have to use js or simply create it with C++ or Java.

    – Bidhan Majhi
    Jan 3 at 6:59








1




1





In Django you don't link the Python file, you link the route defined for your view.

– Klaus D.
Jan 3 at 2:58





In Django you don't link the Python file, you link the route defined for your view.

– Klaus D.
Jan 3 at 2:58













But how will a Python game run in the browser?

– xyres
Jan 3 at 3:20





But how will a Python game run in the browser?

– xyres
Jan 3 at 3:20













Either use Pygame directly or use projects like Titanium or skulpt. But you can not make a web game in python. You have to use js or simply create it with C++ or Java.

– Bidhan Majhi
Jan 3 at 6:59





Either use Pygame directly or use projects like Titanium or skulpt. But you can not make a web game in python. You have to use js or simply create it with C++ or Java.

– Bidhan Majhi
Jan 3 at 6:59












1 Answer
1






active

oldest

votes


















0














Python code cannot be run in the browser, at least directly. There's just no way. See, it doesn't work like a Flash game does. You won't be able to open a Python file in the browser and expect a full shell to run, as there are no browsers out there that even support anything like that. A user can download a Python file from your website and run it on a local shell, but it is not possible to run anything like that directly in the browser. Granted, there are websites that will let you upload code and see the results, but there's a difference between running code on a remote server and running code in the browser. The latter is impossible.



And in regards to your original problem, yes, you have linked correctly. However, make sure that you have linked to the right file, and that the file is spelled correctly and is in the right directory. Keep in mind that they will only be able to view the code, not run it in-browser. (unless you link to an online REPL or shell, which I highly recommend in this circumstance)






share|improve this answer





















  • 1





    Thanks, I will try and see if I can link it to an online shell.

    – Newton Yuan
    Jan 3 at 22:27












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015735%2fhow-do-you-run-a-python-file-in-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Python code cannot be run in the browser, at least directly. There's just no way. See, it doesn't work like a Flash game does. You won't be able to open a Python file in the browser and expect a full shell to run, as there are no browsers out there that even support anything like that. A user can download a Python file from your website and run it on a local shell, but it is not possible to run anything like that directly in the browser. Granted, there are websites that will let you upload code and see the results, but there's a difference between running code on a remote server and running code in the browser. The latter is impossible.



And in regards to your original problem, yes, you have linked correctly. However, make sure that you have linked to the right file, and that the file is spelled correctly and is in the right directory. Keep in mind that they will only be able to view the code, not run it in-browser. (unless you link to an online REPL or shell, which I highly recommend in this circumstance)






share|improve this answer





















  • 1





    Thanks, I will try and see if I can link it to an online shell.

    – Newton Yuan
    Jan 3 at 22:27
















0














Python code cannot be run in the browser, at least directly. There's just no way. See, it doesn't work like a Flash game does. You won't be able to open a Python file in the browser and expect a full shell to run, as there are no browsers out there that even support anything like that. A user can download a Python file from your website and run it on a local shell, but it is not possible to run anything like that directly in the browser. Granted, there are websites that will let you upload code and see the results, but there's a difference between running code on a remote server and running code in the browser. The latter is impossible.



And in regards to your original problem, yes, you have linked correctly. However, make sure that you have linked to the right file, and that the file is spelled correctly and is in the right directory. Keep in mind that they will only be able to view the code, not run it in-browser. (unless you link to an online REPL or shell, which I highly recommend in this circumstance)






share|improve this answer





















  • 1





    Thanks, I will try and see if I can link it to an online shell.

    – Newton Yuan
    Jan 3 at 22:27














0












0








0







Python code cannot be run in the browser, at least directly. There's just no way. See, it doesn't work like a Flash game does. You won't be able to open a Python file in the browser and expect a full shell to run, as there are no browsers out there that even support anything like that. A user can download a Python file from your website and run it on a local shell, but it is not possible to run anything like that directly in the browser. Granted, there are websites that will let you upload code and see the results, but there's a difference between running code on a remote server and running code in the browser. The latter is impossible.



And in regards to your original problem, yes, you have linked correctly. However, make sure that you have linked to the right file, and that the file is spelled correctly and is in the right directory. Keep in mind that they will only be able to view the code, not run it in-browser. (unless you link to an online REPL or shell, which I highly recommend in this circumstance)






share|improve this answer















Python code cannot be run in the browser, at least directly. There's just no way. See, it doesn't work like a Flash game does. You won't be able to open a Python file in the browser and expect a full shell to run, as there are no browsers out there that even support anything like that. A user can download a Python file from your website and run it on a local shell, but it is not possible to run anything like that directly in the browser. Granted, there are websites that will let you upload code and see the results, but there's a difference between running code on a remote server and running code in the browser. The latter is impossible.



And in regards to your original problem, yes, you have linked correctly. However, make sure that you have linked to the right file, and that the file is spelled correctly and is in the right directory. Keep in mind that they will only be able to view the code, not run it in-browser. (unless you link to an online REPL or shell, which I highly recommend in this circumstance)







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 5:35

























answered Jan 3 at 5:18









WAUthethirdWAUthethird

216




216








  • 1





    Thanks, I will try and see if I can link it to an online shell.

    – Newton Yuan
    Jan 3 at 22:27














  • 1





    Thanks, I will try and see if I can link it to an online shell.

    – Newton Yuan
    Jan 3 at 22:27








1




1





Thanks, I will try and see if I can link it to an online shell.

– Newton Yuan
Jan 3 at 22:27





Thanks, I will try and see if I can link it to an online shell.

– Newton Yuan
Jan 3 at 22:27




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015735%2fhow-do-you-run-a-python-file-in-html%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]