PythonでHello World

(20)
https://qiita.com/okhrn/items/4d3c74563154f191ba16


apt install python3

python -V

vim hello.py
print("Hello World!")

python hello.py

--

python -m http.server 8080
--

vim web.py

#!/usr/bin/env python3
import http.server
import socketserver

PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()

vim index.html
<!DOCTYPE html>
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>

python web.py

(10)

apt install python3

python3 -V

vim hello.py
print("Hello World!")

python3 hello.py

--

python3 -m http.server 8080
--

vim web.py

#!/usr/bin/env python3
import http.server
import socketserver

PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()

vim index.html
<!DOCTYPE html>
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>

python3 web.py

 

(8)
dnf install python38


python3.8 -V

vim hello.py
print("Hello World!")

python3.8 hello.py

--

python3.8 -m http.server 8080
--

vim web.py

#!/usr/bin/env python
import http.server
import socketserver

PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()

vim index.html
<!DOCTYPE html>
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>

python3.8 web.py

(2019)
https://www.python.org/


python -V

notepad hello.py
print("Hello World!")

python hello.py

--

python -m http.server 8080
--

notepad web.py

#!/usr/bin/env python
import http.server
import socketserver

PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler

with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()

notepad index.html
<!DOCTYPE html>
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>

python web.py