-1
When accessing through the browser my Python page, it displays the code and does not execute the script.
Follows my code:
#!/usr/bin/python
# cabecalho que informa o browser para renderizar como HTML
print "Content-Type: text/html\n\n"
# o conteudo em si
print "<strong>Hello, world!</strong>"
The browser does not interpret Python. The only language the browser interprets is Javascript. If you want to work with CGI, you need a server (such as Apache or Nginx) and the Python module installed on it (mod_wsgi or uWsgi), so that the SERVER generates HTML pages and sends them to the browser. That way the browser will only show you the same text.
– Seu Madruga
@inovapixel How do I work on the web with Python?
– Gladison
It’s like I said, you need a server running the module responsible for interpreting Python. This is called CGI (common gateway interface), and can be done with Python, Perl, C/C++, and some other languages... These languages are multi-purpose (multi-purpose), they’re not specific to the Web, so getting started with them is more difficult. I recommend that if you want to learn how to program for the Web, start with Php, because it comes ready to run, just download and install programs like XAMPP, WAMPSERVER, VERTRIGO SERVER and etc... They already come with everything ready to program in Php.
– Seu Madruga
The easiest way to get started with python on the web is by using a framework, there are dozens of them, choose a popular Fullstack (Django, Turbogears and Web2py, my favorite is Django) See a list, here.
– Sidon