~momoji.技术架构及算法~
选取python3为开发语言,版本python 3.7.3;
web架构为pyramid;
数据库访问采用sqlalchemy;
使用jinja2模板,也提供api,但非完全前后端分离;
前端使用了echarts2;
考虑该站点依靠iis挂了几个应用,80端口已占就用iis做了application request routing 和 url rewrite,后续考虑换为nginx;
数据库mysql,版本mysql 8.0.16.0;后续考虑换位文件系统;
存储结构具有为单父属性的节点,即tree或者multi-tree;但最终实现可成环的有向图,非dag(因为有向且成环);
momoji.技术架构及算法 by 飞~甜 @ 2019-06-11 14:56:51
切到该章
收藏
从此续写
~坑~
记录一下开发部署过程踩过的坑.
~IIS URL Rewrite问题~
对接qq互联平台的网站应用,在pyramid中采用重定向到qq connect OAuth2的authorize:
#导向qq connect authority页面
@view_config(route_name='qq.auth', renderer='json')
def qqauth_view(request):
url = OauthClient.get_authorize_url()
print("qq.auth.url:",url)
return HTTPFound(location=url )
在独立部署下没有问题,可以让浏览器302重定向到:
https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=xxxx&redirect_uri=http://www.momoji.com.cn/qq/callback&scope=get_user_info,&state=
但采用iis的url rewrite之后,浏览器收到的response header 中Location为http://www.momoji.com.cn/,重定向的url为:http://www.momoji.com.cn/oauth2.0/authorize?response_type=code&client_id=xxxx&redirect_uri=http://www.momoji.com.cn/qq/callback&scope=get_user_info,&state=
应该是iis url rewrite的问题,尝试从pyramid.httpexceptions.HTTPFound类入手看有没有固定response header location为 https://graph.qq.com的方法,没有找到;
思考,若是换一种部署比如nginx做反向代理,难道也要改代码么?不至于啊,还是回到iis url rewrite设置上;
尝试如下规则,放置于第一行,经测试有效:
<rule name="https://graph.qq.com/oauth2.0/authorize" stopProcessing="true">
<match url="oauth2.0/authorize?(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="https://graph.qq.com/oauth2.0/authorize?{R:1}" redirectType="Found" />
</rule>
即:若匹配到url域名/之后部分为oauth2.0/authorize?(.*)则重定向到https://graph.qq.com/oauth2.0/authorize?{R:1}这里;
这里踩了一个坑,明确了,在匹配正则表达式时,不是对整个url写,而是对域名/之后的部分进行匹配;另,包括.?这些字符不需要转义(转义也可).
IIS URL Rewrite问题 by 飞~甜 @ 2019-06-25 09:46:08
切到该章
收藏
从此续写
last by 飞~甜 @ 2019-06-25 09:46:08
章节模式
复制地址