超快twilio短信响应api
pyrowire的Python项目详细描述
火线
你需要创建一个短信应用程序吗?是的,你知道。 pyrowire是一个框架,您可以使用它快速创建基于twilio的sms/mms应用程序。
许可证
Pyrowire根据BSD 3子句许可证获得许可,可以查看here。
快速启动
- 在本快速入门中,假设您在Heroku和Twilio都有一个帐户,并且至少安装了以下内容:
- 点
- virtualenv
在虚拟环境根目录中,执行:
$ pip install pyrowire && pyrowire --init
这将安装pyrowire,并将以下文件复制到根文件夹中:
- my_app.py(应用程序文件)
- my_settings.py(配置文件)
- Procfile(heroku过程文件)
- requirements.txt(pip需求文件)
使用量
$ ENV=(DEV|STAGING|PROD) [RUN=(WEB|WORKER)] [TOPIC=] python my_app.py
示例应用程序
下面是my app.py文件(通过运行pyrowire-init创建)的外观:
importpyrowireimportmy_settingspyrowire.configure(settings=my_settings)# all app.processor methods need to be annotated with the topic for which they process# and take one kwarg, 'message_data'@pyrowire.handler(topic='my_topic')defmy_processor(message_data=None):pass# all pyro.filter methods need to be annotated with the name of the filter# and take one kwarg, 'message_data'@pyrowire.validator(name='my_validator')defmy_filter(message_data=None):passif__name__=='__main__':pyrowire.run()
如您所见,这相当简单;首先,您将获得处理程序和验证器的占位符。 处理程序是为twilio应用程序编写业务逻辑的地方,可以添加额外的验证器 如果需要,或者全部移除。有关详细信息,请参见相应的部分。
有关完整的文档和教程,请访问我们的documentation page。