Tag Archives: debian

Deploy Flask Application to Apache Webserver

  • Install mod_wsgi

sudo apt-get install libapache2-mod-wsgi

  • Enable wsgi module

sudo a2enmod wsgi

sudo systemctl restart apache2

  • Create .wsgi file with below content

from yourapp import app as application

  • Configure a new site in Apache2
<VirtualHost 127.0.0.1:80>
    ServerName site.api

    WSGIDaemonProcess site user=www-data group=www-data threads=5 home=/var/www/site
    WSGIScriptAlias / /var/www/site/app.wsgi

    <Directory /var/www/site>
        WSGIProcessGroup site
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

    WSGIPassAuthorization On

</VirtualHost>
  • Enable the site and reload Apache2

Bluetooth controlled robot

Microcontroller – PIC12F1840
Bluetooth Module – SparkFun Bluetooth Modem – BlueSMiRF Silver
Operating System – Debian 8
Pic Programmer – PICkitâ„¢ 3 In-Circuit Debugger
IDE – MPLAB X IDE
Compiler Toolchain – MPLAB XC8 Compiler

Code Snippet

#include "mcc_generated_files/mcc.h"
/*
                         Main application
 */
#define MotorA_P RA0
#define MotorA_N RA4
#define MotorB_P RA2
#define MotorB_N RA1
unsigned char ch = '0';
unsigned char oldch = '0';
void pauseMotor();
void main(void) {
    // initialize the device
    SYSTEM_Initialize();
    MotorA_P = 0;
    MotorA_N = 0;
    MotorB_P = 0;
    MotorB_N = 0;
    while (1) {
        ch = EUSART_Read();
        if (ch == 'U') {
            pauseMotor();
            MotorA_P = 1;
            MotorA_N = 0;
            MotorB_P = 1;
            MotorB_N = 0;
        } else if (ch == 'D') {
            pauseMotor();
            MotorA_P = 0;
            MotorA_N = 1;
            MotorB_P = 0;
            MotorB_N = 1;
        } else if (ch == 'L') {
          
            MotorA_P = 1;
            MotorA_N = 0;
            MotorB_P = 0;
            MotorB_N = 0;
            __delay_ms(200);
            MotorA_P = 1;
            MotorA_N = 0;
            MotorB_P = 1;
            MotorB_N = 0;
        } else if (ch == 'R') {
            MotorA_P = 0;
            MotorA_N = 0;
            MotorB_P = 1;
            MotorB_N = 0;
             __delay_ms(200);
            MotorA_P = 1;
            MotorA_N = 0;
            MotorB_P = 1;
            MotorB_N = 0;
        } else if (ch == 'S') {
            pauseMotor();
            MotorA_P = 1;
            MotorA_N = 0;
            MotorB_P = 1;
            MotorB_N = 0;
        } else if (ch == 'X') {
            MotorA_P = 0;
            MotorA_N = 0;
            MotorB_P = 0;
            MotorB_N = 0;
        }
        if (ch != oldch) {
            oldch = ch;
        }
    }
}
void pauseMotor() {
    if (ch != oldch) {
        MotorA_P = 0;
        MotorA_N = 0;
        MotorB_P = 0;
        MotorB_N = 0;
        __delay_ms(400);
    }
}