Procházet zdrojové kódy

Загрузить файлы ''

gr714_vidvl před 4 měsíci
rodič
revize
efead06efe
2 změnil soubory, kde provedl 31 přidání a 0 odebrání
  1. 12 0
      index.html
  2. 19 0
      server-1.2.py

+ 12 - 0
index.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-wirth, initial-scale=1.0">
+    <title>IP and mask</title>
+</head>
+<body>
+    <h1>You'r IP: {{ ip }}</h1>
+    <h2>Mask: {{ mask }}</h2>
+</body>
+</html>

+ 19 - 0
server-1.2.py

@@ -0,0 +1,19 @@
+from flask import Flask, request, render_template
+import ipaddress
+
+
+app = Flask(__name__)
+
+
+@app.route('/')
+def index():
+    user_ip = request.remote_addr
+
+    subnet_mask = '255.255.255.0'
+
+    network = ipaddress.ip_network(f'{user_ip}/{subnet_mask}', strict=False)
+
+    return render_template('index.html', ip=user_ip, mask=subnet_mask)
+
+if __name__ == '__main__':
+    app.run(debug=True)