SMS送信ビューの追加
をレンダリングするビューを追加する。 Jinja2 テンプレートを作成します。このテンプレートは templates/index.html:
@app.route('/')
def index():
""" A view that renders the Send SMS form. """
return render_template('index.html')
次のHTMLは、Bootstrap CSSフレームワークを含み、2つのフィールドを持つフォームをレンダリングします: to_number 宛先の電話番号と messageユーザーはSMSメッセージを入力することができます。
<h1>Send an SMS</h1>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
<h1>Send an SMS</h1>
<form action="/send_sms" method="POST">
<div class="form-group"><label for="destination">Phone Number</label>
<input id="to_number" class="form-control" name="to_number" type="tel" placeholder="Phone Number" /></div>
<div class="form-group"><label for="message">Message</label>
<textarea id="message" class="form-control" name="message" placeholder="Your message goes here"></textarea></div>
<button class="btn btn-default" type="submit">Send SMS</button>
</form>
</div>
Python、Flask、NexmoでSMSメッセージを送信する方法
このチュートリアルでは、Nexmo Pythonライブラリを利用したPythonによるSMS送信を紹介します。REPLからSMSを送信する方法から始まり、SMS機能を持つシンプルなflaskアプリを構築する方法を紹介します。
手順
1
このチュートリアルの紹介2
Prerequisites3
Vonage Python Server SDKのインストール4
Python REPLからSMSを送信する5
SMS送信Flaskアプリのセットアップ6
SMS送信ビューの追加7
Flaskサーバーの実行8
フォーム投稿の処理9
次はどうする?