How can I integrate a python function inside a website? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can I integrate a python function inside a website?

Lets say I created a simple html-css website with a button, and I want that button to do a function wrote in python, so how can I integrate python functions inside a website? (I need a big picture, not necessarily in details)

5th Nov 2019, 9:00 AM
edward 🇷🇴
edward 🇷🇴 - avatar
8 Answers
+ 6
Am văzut la cineva aici pe sololearn folosind ceva numit "brython". Nu sunt sigur dacă asta este ceea ce cauți, dar merită menționat.
5th Nov 2019, 9:57 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 5
You can run your python script from JavaScript (impossible without js), everytime the button is clicked JS runs the python file and gets the output, to show it later in the website. But, this is not safe as your python script can be publicly accessed, and cause security issues. The second and probably the best way is to use python as backend language, learn flask or django frameworks, and then create the website using them, this will allow tou to easily run python scripts directly, without having to use different languages.
5th Nov 2019, 10:57 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Look up Brython
7th Nov 2019, 2:48 AM
Sonic
Sonic - avatar
+ 2
Mirielle🐶 [Inactive] he did not ask for alert, he said how to run python scripts in general, that have nothing to do with the web, for example making a calculus or manipulating a picture; this can be done without the need of javascript.
5th Nov 2019, 12:00 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
KitKat [Chocolate] ▶ 🍫 am gasit zilele trecute cateva variante, printre care si brython, ma interesa mai mult pentru api-uri si diverse actiuni, si imi eta mai usor in python, dar ma uit de cateva zile si peste js... Mersi :)
5th Nov 2019, 5:32 PM
edward 🇷🇴
edward 🇷🇴 - avatar
+ 1
Aymane Boukrouh [Inactive] makes sens, everything I want is duable in js as well, but I only know python (beginner-intermediate), I touched js these days, it was easy to learn basics, but I like python more. I will go deeper and maybe I'll give a chance for flask/django too. Thanks!
5th Nov 2019, 5:41 PM
edward 🇷🇴
edward 🇷🇴 - avatar
+ 1
Good info :) nice for fullstack!
7th Nov 2019, 1:38 AM
Lev
0
Mirielle🐶 [Inactive] thanks, i'm looking over js these days for my needs
5th Nov 2019, 5:35 PM
edward 🇷🇴
edward 🇷🇴 - avatar