Project_Folder
|
|----- templates/
| |---- layout.html
| |---- ....
|----- static/
| |---- js/
| | |--- script.js
| |---- css/
| | |--- main.css
|
|----- app.py
Last active
February 26, 2017 08:59
-
-
Save manashmandal/0fcef8fb200daf6e2ac86b20b490f08f to your computer and use it in GitHub Desktop.
Workshop : Day 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import flask library | |
from flask import Flask | |
# Initialize the application | |
app = Flask(__name__) | |
# Define a route using Python Decorator | |
@app.route('/') | |
def hello_world(): | |
return "<h1>Hello, KUETians!</h1>" | |
# A simple route without passing value | |
@app.route('/my_name_is') | |
def get_my_name(): | |
return "<h1>No name found!</h1>" | |
# A route with value passing | |
@app.route('/say_my_name/<name>') | |
def say_my_name(name): | |
return "<h1>Your name is: " + name + "</h1>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template | |
app = Flask(__name__) | |
@app.route('/say_my_name/<name>') | |
def say_my_name(name): | |
return render_template('name.html', name=name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var johnny_five = require("johnny-five"); | |
var led_pin = 13; | |
//Change this COM Port | |
var COM = 'COM3'; | |
var arduino = new johnny_five.Board(COM); | |
arduino.on("ready", function() { | |
var led = new johnny_five.Led(led_pin); | |
led.blink(500); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var five = require('johnny-five'); | |
var requestify = require('requestify'); | |
var board = new five.Board({ port: "COM3" }); | |
var roll = '1203043'; | |
var batch = '2k12'; | |
var ledpin = 13; | |
var success = false; | |
//Enter roll and batch | |
requestify.get('http://webwork.manash.me/esp8266.php?apples=' + batch + '&oranges=' + roll).then(function(response) { | |
response.getBody(); | |
console.log(response.body); | |
var pos = response.body.search('SUCCESS'); | |
if (pos >= 0) { | |
success = true; | |
} | |
}); | |
board.on('ready', function() { | |
var led = new five.Led(ledpin); | |
if (success) { | |
led.blink(500); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Workshop | 2K17</title> | |
</head> | |
<body> | |
<h1> | |
{% block placeholder %} {% endblock %} | |
</h1> | |
<h2>From Breaking Bad</h2> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'main.html' %} | |
{% block placeholder %} | |
Say my name ... | |
<br/> | |
{{ name }} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment