Memo of Flask
Flask
- Welcome to Flask — Flask Documentation (1.1.x)
- Flask (web framework) - Wikipedia Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries.
- Installation — Flask Documentation (1.1.x)
- Quickstart — Flask Documentation (1.1.x)
- Static Files — Flask Documentation (1.1.x)
- staticの扱い
- Adding a favicon — Flask Documentation (1.1.x)
- Adding an iOS home screen icon for your website | Create.net
mod_wsgi and Apache2
- mod_wsgi (Apache) — Flask Documentation (1.1.x)
- Web Server Gateway Interface - Wikipedia The Web Server Gateway Interface (WSGI) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language.
- mod_wsgiはpipで入れようねって話 - Qiita よく分からん。結局Flask公式通りに、mod_wsgiもapt-getでinstallした。
- mod_wsgiをなぜかpipでインストールできない時 - Qiita RuntimeError: The 'apxs' command appears not to be installed or is not executable.
- raspbian stretch - Apache2 on Raspberry pi 3 - cannot install WSGI module - Raspberry Pi Stack Exchange sudo apt update
- python - Invalid command WSGIDaemonProcess Deploy Django application on CentOS 6.7 - Stack Overflow
- venv環境ではactivate_this.pyを実行する処理を書いてね、とあるが、activate_this.pyがない。
- python - No activate_this.py file in venv / pyvenv - Stack Overflow ええ、もうないです。
- mod wsgi - How can I activate a pyvenv vitrualenv from within python? (activate_this.py was removed?) - Stack Overflow ええ、もうないです。
- virtualenv/activate_this.py at main · pypa/virtualenv · GitHub Pathを調整する小さいスクリプトです。
- Virtual Environments — mod_wsgi 4.8.0 documentation mod_wsgi公式
- Minimal Apache configuration for deploying a flask app (Ubuntu 18.04) | Codementor 環境構築例: Apache2, mod_wsgi and Flask
- Apache To Python For mod_wsgi - Qiita 環境構築例: Apache2 and mod_wsgi
- ラズパイにApache2を導入してみる - Qiita 環境構築例: Apache2 on Raspberry Pi
Jinja2
from jinja2 import Template template = Template('Hello {{ name }}!') template.render(name='John Doe')
from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates')) template = env.get_template('hello.html') with open('output.html', 'w') as f: f.write(template.render(name='John Doe'))
- python - Remove unnecessary whitespace from Jinja rendered template - Stack Overflow
- htmlから無駄なスペースを除く。
app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True
Abema API
見やすいAbema番組表がほしい、というのがそもそものモチベーション。
- abemaTV の番組表 json | ニコラボ Authorization:bearerの値はWeb browserのdev toolで確認。
- AbemaTV Timetable Viewer のソースコード
Environment
- Python 3.7.3
- Flask 1.1.2
- mod-wsgi 4.7.1
- Apache/2.4.38
- Raspberry Pi 2 Model B