ZoomQuiet avatar ZoomQuiet committed 3c1b815

up for SAE new version

Comments (0)

Files changed (4)

+120421 ZQ 使用全新 saecloud 重构金山云安全的 SAE 应用,v2
 110323 ZQ 快速建立了基于GAE 的人工查询服务代码
 .hg
 +-- default     默认分支包含主要的文档
 +-- GAE         可部署在GAE上的版本
++-- SAE         可部署在SAE上的版本
++-- bottle      本地运行的版本
+`-- tools       相关实验性支持脚本
 
 
 依赖
 -------------------------------------------------------------------------------
-Bottle+GAE
+Bottle
 
 部署
 -------------------------------------------------------------------------------
 
-
-记要
--------------------------------------------------------------------------------
-110323  Zoom.Quiet 创建
-
 ---
 name: urisaok
-version: 1
+version: 2
 ...
 # -*- coding: utf-8 -*-
 VERSION = "urisaok v11.12.28"
 '''网址云RESTful API 包装服务:
-    - 111226 clone into SAE
-    - 110324 clone into GAE
-    - 110323 init.
 依赖:
     + bottle
+    + SAE
 '''
-
-from bottle import Bottle, request, run
-
 import sae
 import urllib2 as urilib
+from bottle import Bottle, request
 
 import base64
 import time
     SECRET = "99fc9fdbc6761f7d898ad25762407373"
     OPEN_HOST = "open.pc120.com"
     APITYPE = "/phish/"
-    PHISHTYPE={'-1':'未知'
+    PHISHTYPE = {'-1':'未知'
         ,'0':'非钓鱼'
         ,'1':'钓鱼'
         ,'2':'网站高风险,有钓鱼嫌疑'
         }
-
 # init all var
 cfg = Borg()
 
 
 @app.route('/')
 def hello():
-    return "Hello, world! - Bottle @ SAE 4 urisaok! for knoss YY talking.."
+    return "Hello, world! - Bottle @ SAE 4 urisaok!{v12.04.23} from YY talking.."
 
-@app.route('/ask/:uri')
-def ask(uri):
+@app.route('/chk/', method="POST")
+def chk():
+    uri = request.forms.get('uri')
     print uri
-    result = _askCloud(cfg.APITYPE,uri)
-    return "/ask %s"% result
-
-@app.route('/chk', method='POST')
-def chk():
-    print dir(app)
-    uri = request.forms.get('uri')
-    #print uri
-    result = _askCloud(cfg.APITYPE,uri)
-    #result = 'testing...'
+    result = _askCloud(cfg.APITYPE, uri)
     return "/chk %s"% result
 
-
 def _askCloud(api_path, url):
     args = __genQueryArgs(api_path, url)
     key_values = [("%s=%s" % (k, v)) for k, v in args.iteritems()]
-    api_url = "http://%s/%s/"%(cfg.OPEN_HOST,api_path) + "?" + "&".join(key_values)
+    api_url = "http://%s/%s/"% (cfg.OPEN_HOST, api_path) + "?" + "&".join(key_values)
     print api_url
     result = eval(urilib.urlopen(api_url).read())
     print type(result)
     print result
     if result['success'] == 1:
         doc = result['phish']
-        return "%s:: %s"%(doc,cfg.PHISHTYPE[str(doc)])
+        return "%s:: %s"% (doc, cfg.PHISHTYPE[str(doc)])
     else:
         return result
 
     return base_string
 
 application = sae.create_wsgi_app(app)
-
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.