SlideShare una empresa de Scribd logo
1 de 12
Descargar para leer sin conexión
Flask アプリで Sphinx
ドキュメントを公開する
2016-05-13 Fri.
白ヤギコーポレーション 森本 哲也
Shiroyagi.corp. All rights reserved
概要
● Flask
○ Python の WAF の1つ
○ シンプルな Web アプリの開発
○ Blueprints というモジュール機構
● Sphinxドキュメントのデプロイ
○ 実用例: 管理画面内で仕様書を公開
Flask
Shiroyagi.corp. All rights reserved
Flask に関連する最近の話題
● GitHub 上の Python フレームワークで☆1位
● Pallets プロジェクトに移管?
○ https://www.palletsprojects.com/
○ https://www.palletsprojects.com/blog/hello/
● Flask のメンテナンス状況?
○ 2013-06-14, 0.10.1, https://pypi.python.org/pypi/Flask
○ 2016-05-09, master, https://github.com/pallets/flask/commits/master
Shiroyagi.corp. All rights reserved
Flask の設計
● マイクロフレームワークという冠をかぶった重量級設計
○ あちこちで処理をフックできる (feature creep?)
○ シグナル
■ http://flask.pocoo.org/docs/0.10/signals/
○ Request Context
■ http://flask.pocoo.org/docs/0.10/reqcontext/
○ Application Context
■ http://flask.pocoo.org/docs/0.10/appcontext/
Shiroyagi.corp. All rights reserved
多彩な Flask Extension
● Flask Extension もいっぱい
○ がんばればそこそこのアプリも作れるよ!でも ...
● @methane: Flaskの闇
○ 「理想は理想であると見抜けない人には
(Flaskを使うのは)難しい」
○ 循環インポート問題を避ける (´・ω・`)
■ 実際に開発している管理画面アプリの例
Sphinxドキュメント
のデプロイ
Shiroyagi.corp. All rights reserved
デモ
● 要件: 管理画面内で仕様書を見たい
○ 1つの解: Flask アプリ内に直接埋め込んだ
Shiroyagi.corp. All rights reserved
Flask アプリ内にドキュメントディレクトリを作る
● アプリケーションのリポジトリ内に
直接ドキュメントディレクトリを埋め込む
○ git submodule
○ 別のリポジトリを管理する機能
ディレクトリ構成
api_admin/
├── __init__.py
├── apps
│ ├── __init__.py
...
├── doc
│ ├── build
│ └── source
...
Sphinxドキュメント
Shiroyagi.corp. All rights reserved
Flask アプリで静的ファイルを扱う
● flask.send_from_directory(directory, filename, **options)
○ send_file() で指定したディレクトリからファイルを送信する
○ 簡単に静的ファイルを公開するセキュアな方法
from flask import send_from_directory
@app.route('/doc/<path:path>')
@login_required
def doc(path):
return send_from_directory(app.config['DOCUMENT_DIR'], path)
Shiroyagi.corp. All rights reserved
flask.send_from_directory をもう少し
● 簡単に静的ファイルを公開するセキュアな方法
● Flask の helper.py を読んでみる
○ 絶対パス指定禁止
○ ディレクトリトラバーサル対策
Shiroyagi.corp. All rights reserved
まとめ
● Flask のメンテナンスが今後どうなっていくのかに注目
● Flask で Sphinx ドキュメントを公開するのは簡単

Más contenido relacionado

Último

Último (12)

Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Flask アプリで Sphinx ドキュメントを公開する

  • 1. Flask アプリで Sphinx ドキュメントを公開する 2016-05-13 Fri. 白ヤギコーポレーション 森本 哲也
  • 2. Shiroyagi.corp. All rights reserved 概要 ● Flask ○ Python の WAF の1つ ○ シンプルな Web アプリの開発 ○ Blueprints というモジュール機構 ● Sphinxドキュメントのデプロイ ○ 実用例: 管理画面内で仕様書を公開
  • 4. Shiroyagi.corp. All rights reserved Flask に関連する最近の話題 ● GitHub 上の Python フレームワークで☆1位 ● Pallets プロジェクトに移管? ○ https://www.palletsprojects.com/ ○ https://www.palletsprojects.com/blog/hello/ ● Flask のメンテナンス状況? ○ 2013-06-14, 0.10.1, https://pypi.python.org/pypi/Flask ○ 2016-05-09, master, https://github.com/pallets/flask/commits/master
  • 5. Shiroyagi.corp. All rights reserved Flask の設計 ● マイクロフレームワークという冠をかぶった重量級設計 ○ あちこちで処理をフックできる (feature creep?) ○ シグナル ■ http://flask.pocoo.org/docs/0.10/signals/ ○ Request Context ■ http://flask.pocoo.org/docs/0.10/reqcontext/ ○ Application Context ■ http://flask.pocoo.org/docs/0.10/appcontext/
  • 6. Shiroyagi.corp. All rights reserved 多彩な Flask Extension ● Flask Extension もいっぱい ○ がんばればそこそこのアプリも作れるよ!でも ... ● @methane: Flaskの闇 ○ 「理想は理想であると見抜けない人には (Flaskを使うのは)難しい」 ○ 循環インポート問題を避ける (´・ω・`) ■ 実際に開発している管理画面アプリの例
  • 8. Shiroyagi.corp. All rights reserved デモ ● 要件: 管理画面内で仕様書を見たい ○ 1つの解: Flask アプリ内に直接埋め込んだ
  • 9. Shiroyagi.corp. All rights reserved Flask アプリ内にドキュメントディレクトリを作る ● アプリケーションのリポジトリ内に 直接ドキュメントディレクトリを埋め込む ○ git submodule ○ 別のリポジトリを管理する機能 ディレクトリ構成 api_admin/ ├── __init__.py ├── apps │ ├── __init__.py ... ├── doc │ ├── build │ └── source ... Sphinxドキュメント
  • 10. Shiroyagi.corp. All rights reserved Flask アプリで静的ファイルを扱う ● flask.send_from_directory(directory, filename, **options) ○ send_file() で指定したディレクトリからファイルを送信する ○ 簡単に静的ファイルを公開するセキュアな方法 from flask import send_from_directory @app.route('/doc/<path:path>') @login_required def doc(path): return send_from_directory(app.config['DOCUMENT_DIR'], path)
  • 11. Shiroyagi.corp. All rights reserved flask.send_from_directory をもう少し ● 簡単に静的ファイルを公開するセキュアな方法 ● Flask の helper.py を読んでみる ○ 絶対パス指定禁止 ○ ディレクトリトラバーサル対策
  • 12. Shiroyagi.corp. All rights reserved まとめ ● Flask のメンテナンスが今後どうなっていくのかに注目 ● Flask で Sphinx ドキュメントを公開するのは簡単