Code Monkey home page Code Monkey logo

flask-guestbook's Introduction

This is used in the demonstration of development of Ansible Playbooks.

Below are the steps required to get this working on a base linux system.

  • Install all required dependencies
  • Start Web Server

1. Install system dependencies

Python and its dependencies

apt-get install -y python python-setuptools python-dev build-essential python-pip python-mysqldb

2. Install application dependencies

Install python dependencies

pip install configparser
pip install flask
pip install flask-sqlalchemy

3. Download the application

git clone https://github.com/jrrickerson/flask-guestbook /opt/flask-guestbook

4. Start Web Server

Ensure the application is not already running

kill $(ps -ef |grep -v grep | grep -w flask |awk '{print $2}')

Start web server in a background process

FLASK_APP=/opt/flask-guestbook/app.py nohup flask run -h 0.0.0.0 -p 8080 &

5. Test

List messages
curl http://<IP>:8080/signatures

Write a message
curl -X POST http://<IP>:8080/signatures?message="my message"

Add a mysql database

1. Install and Configure Database

Install MySQL database

apt-get install -y mysql-server mysql-client

Allow any host to connect

sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/mysql.conf.d/mysqld.cnf

2. Start Database Service

  • Start the database service

    service mysqld start
    
  • Create database and database users

    # mysql -u <username> -p
    
    mysql> CREATE DATABASE guestbook;
    mysql> GRANT ALL ON *.* to db_user@'%' IDENTIFIED BY 'Passw0rd';
    
  • Configure database credentials and parameters for the app The app looks for a configuration file at '/opt/guestbook/vars.ini'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.