- Я пробовал простой python-сокет, у меня есть bootstrap.min.css в том же каталоге registro.html, но это не стиль загрузки из bootstrap, registro.html, bootstrap.min.css и soket_test. Пи находятся в том же каталоге.
- Я был сделать запрос из любого браузера.
socket_test.py
#!/usr/bin/env python
import socket
import json
import re
def getValorArreglo(parametros, clave):
for indice in parametros:
if indice.split('=')[0] == clave:
return indice.split('=')[1]
return None
'''def setSiguienteVista(action,parametros):
if action != None and action == '/formulario':'''
host = '127.0.0.1'
port = 8791
server_sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # Create a socket object
server_sock.bind((host , port)) # Bind to the port
server_sock.listen(5) # Now wait for client connection.
print ('Entering infinite loop; hit CTRL-C to exit')
while True:
# Establish connection with client.
client_sock, (client_host, client_port) = server_sock.accept()
print ('Got connection from', client_host, client_port)
request = b""
contador = 0
while not b"\r\n\r\n" in request:
request += client_sock.recv(1000) # should receive request from client. (GET ....)
client_sock.send(b'HTTP/1.0 200 OK\n')
client_sock.send(b'Content-Type: text /html\n')
client_sock.send(b'\n') # header and body should be separated by additional newline
# you can paste your 2 text field html here in the <body>
HtmlFile = open('registro.html','r')
registro = HtmlFile.read()
client_sock.send(registro)
client_sock.close()
registro.html
<!DOCTYPE html>
<html>
<head>
<title>Proyecto Sistemas Distribuidos</title>
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
<form method="post" action="formulario"class="form-group" >
<div class="form-row etiqueta_principal">
<label class="text-label-principal">REGISTRO DE BACHILLER ASPIRANTE</label>
</div>
<div class="form-row">
<div class="form-group col-md-3 item-div">
<label class="col-md-12 item-label" for="nombre1">Primer Nombre</label>
<input type="text" class="form-control" id="nombre1" name="nombre1" placeholder="Ingrese primer nombre"
required>
</div>
<div class="form-group col-md-3 item-div">
<label class="col-md-12 item-label" for="nombre2">Segundo Nombre</label>
<input type="text" class="form-control" id="nombre2" name="nombre2"
placeholder="Ingrese segundo nombre">
</div>
<div class="form-group col-md-3 item-div">
<div class="item-div button-div">
<button type="submit" class="btn btn-secondary">Enviar Solicitud</button>
</div>
</div>
</form>
</body>
</html>