Example #1
0
import socket
import DataBase

DataBase.CREATE_DATABASE("python_tienda_db")
DataBase.CREATE_TABLE("tienda", "producto", "precio")


class Servidor():
    def __init__(self):
        self.mi_socket = socket.socket()
        self.mi_socket.bind(("", 9090))
        self.mi_socket.listen(1)
        conection, direccion = self.mi_socket.accept()

        while True:
            while True:
                conection.send(
                    "\n1.[VER PRODUCTOS]    \n2.[AGREGAR PRODUCTOS] \n3.[EDITAR PRODUCTOS]  \n4.[ELIMINAR PRODUCTOS]    \n\n0.[SALIR]\n"
                    .encode())
                try:
                    msj = conection.recv(1024)
                    if int(msj) > 4:
                        msj = "error"
                    msj = int(msj)
                    break
                except ValueError:
                    conection.send("\n\n<<OpciĆ³n Invalida>>\n\n".encode())

            print("[]: " + str(msj))
            if (msj == 0):
                break