自分のコンピュータを使用している場合は、XAMPP(またはWAMPPが動作する)というソフトウェアをインストールします。これは基本的にあなたのコンピュータ上でのみ動作するウェブサイトサーバーです。次に、それがインストールされたら、xamppフォルダーに移動し、htdocsフォルダーをダブルクリックします。今あなたがする必要があるのは、htmlファイルを作成することです(私はrunpython.htmlと呼ぶつもりです)。
<form action = "file_name.py" method = "POST">
<input type = "submit" value = "Run the Program!!!">
</form>
今、Pythonのファイルでは、我々は基本的に印刷しようとしている(必要に応じてと入力)
あなたのHTML本体に、この中に追加(同様のhtdocsするのpythonファイルを移動することを忘れないでください)アウトHTMLコード。
#We will need a comment here depending on your server. It is basically telling the server where your python.exe is in order to interpret the language. The server is too lazy to do it itself.
import cgitb
import cgi
cgitb.enable() #This will show any errors on your webpage
inputs = cgi.FieldStorage() #REMEMBER: We do not have inputs, simply a button to run the program. In order to get inputs, give each one a name and call it by inputs['insert_name']
print "Content-type: text/html" #We are using HTML, so we need to tell the server
print #Just do it because it is in the tutorial :P
print "<title> MyPythonWebpage </title>"
print "Whatever you would like to print goes here, preferably in between tags to make it look nice"
これはpython webではなく、python web framework e、g、webpyまたはdjangoなどを設定し、mod_pythonでappacheを設定する必要があります。 –
ウィスキーを試してみよう! :D "WSGI"(Webサーバーゲートウェイインターフェイス)。 – Arunmu
PajamasやSkulptなどのフレームワークを使用して、Webページ(クライアント側)でPythonを実行することができます。 –