# A very simple Flask Hello World app for you to get started with...
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello from Flask!
Страница TEST'
@app.route('/test/')
def test():
return '
TEST
Главная страница'
@app.route('/hello/')
@app.route('/hello/')
def hello(name=None):
return render_template('hello.html', name=name)
Создаём папку templates и размещаем в ней файл 'hello.html'
Hello from Flask
{% if name %}
Hello {{ name }}!
{% else %}
Hello World!
{% endif %}
=== Изучаем HTML-CSS ===
https://www.khanacademy.org/computing/computer-programming/html-css
=== Flask ===
* http://flask-russian-docs.readthedocs.io/ru/latest/quickstart.html
* http://flask.pocoo.org/docs/0.12/quickstart/
* https://flask-russian-docs.readthedocs.io/ru/latest/
* http://ru.wikibooks.nym.su/wiki/Flask
=== Flask для Telegram ===
# A very simple Flask Hello World app for you to get started with...
# http://messagu.ru/telegram/python-bot-dlya-telegram-sozdayom-svoego-pervogo-robota-v-telegram-pri-pomoshhi-python-3
# https://youtu.be/QmGYc7aWpd4
# https://youtu.be/Al7hkU6RO9M
###
# https://help.pythonanywhere.com/pages/InstallingNewModules
# pip3.6
# pip3.6 install requests --user pwhich
# pip3.6 install flask-sslify --user pwhich
# https://api.telegram.org/bot/setWebhook?url=https://you_login.pythonanywhere.com/
from flask import Flask
from flask_sslify import SSLify
from flask import request
from flask import jsonify
import requests
import config
token = config.token
URL = "https://api.telegram.org/bot{}/".format(token)
print(URL)
app = Flask(__name__)
sslify = SSLify(app)
'''
def get_updates():
url = URL + "getUpdates"
r = requests.get(url)
return r.json()
'''
def send_message(chat_id, text="test"):
url = URL + "sendMessage"
answer = {'chat_id': chat_id, 'text': text}
r = requests.post(url, json=answer)
return r.json()
def print_mess(mess):
print(mess)
@app.route('/', methods=['POST','GET'])
def index():
if request.method == 'POST':
r = request.get_json()
chat_id = r['message']['chat']['id']
message = r['message']['text']
send_message(chat_id, "Ты сказал "+ message)
return jsonify(r)
print_mess("Hello")
return 'Hello from Flask! Всем привет!!!
dfsdfdsf '
@app.route('/1/')
def hello_world1():
print ("Страница 1")
return 'Страница 1
'
==== Motion detection on the Raspberry Pi with multiple cameras ====
https://www.pyimagesearch.com/2016/01/18/multiple-cameras-with-the-raspberry-pi-and-opencv/
http://astrobeano.blogspot.ru/2012/08/raspberry-pi-with-two-webcams.html
https://raspberrypi.stackexchange.com/questions/48013/how-to-capture-images-from-2-webcams-parallely-using-raspberry-pi
* [[rfid-code]]