/test2017

Ormuco Test 2017-1

Primary LanguageHTML

#Simple Web Form using Flask + MySQL

This is a simple app that contain a form to fill a simple poll, the homepage hold the form and the secondary page (Database) will display the registry entries (work in progress)

It uses ANSIBLE to provision and deploy the web app. You must have an Ubuntu 14.04 server and have already set up ssh public key authentication on it.

How to use

  • Install ansible on your computer (sudo pip install ansible).

  • Clone this repo and move in to the ansible folder, edit the host file with your data

  • edit the file vars.yml to include your settings

  • Run the playbook: cd ansible

    ansible-playbook -i hosts provision.yml

MySQL DB

This projec uses a simple mysql database, it contain just one table and a stored procedure. To create the DB we move in mysql cli and excecute the commands:

CREATE DATABASE "your_db_name_here";

To create the user table:

CREATE TABLE `your_db_name_here`.`tbl_user` (
  `user_id` BIGINT NULL AUTO_INCREMENT,
  `user_name` VARCHAR(45) NULL,
  `user_color` VARCHAR(45) NULL,
  `user_pet` VARCHAR(45) NULL,
  PRIMARY KEY (`user_id`));

To create the stored Procedure:

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_createData`(
    IN p_name VARCHAR(45),
    IN p_color VARCHAR(45),
    IN p_pet VARCHAR(45)
)
BEGIN 
        insert into tbl_user
        (
            user_name,
            user_color,
            user_pet
        )
        values
        (
            p_name,
            p_color,
            p_pet
        );
END$$
DELIMITER ;

In ansible/files/ there is the simple db used in this proyect.