ZoomQuiet avatar ZoomQuiet committed 1e8ea75

simple hollo world demo

Comments (0)

Files changed (1)

 # -*- coding: utf-8 -*-
-VERSION = "urisaok v11.12.28"
-'''网址云RESTful API 包装服务:
-    - 111226 clone into SAE
-    - 110324 clone into GAE
-    - 110323 init.
-依赖:
-    + bottle
-'''
+import sae
 
-from bottle import Bottle, request
-
-import sae
-import urllib2 as urilib
-
-import base64
-import time
-from hashlib import md5
-
-class Borg():
-    '''base http://blog.youxu.info/2010/04/29/borg
-        - 单例式配置收集类
-    '''
-    __collective_mind = {}
-    def __init__(self):
-        self.__dict__ = self.__collective_mind
-    APPKEY = "k-60666"
-    SECRET = "99fc9fdbc6761f7d898ad25762407373"
-    OPEN_HOST = "open.pc120.com"
-    APITYPE = "/phish/"
-    PHISHTYPE = {'-1':'未知'
-        ,'0':'非钓鱼'
-        ,'1':'钓鱼'
-        ,'2':'网站高风险,有钓鱼嫌疑'
-        }
-
-# init all var
-cfg = Borg()
-
-app = Bottle()
-
-@app.route('/')
-def hello():
-    return "Hello, world! - Bottle @ SAE 4 urisaok!{v12.01.12} from YY talking.."
-
-@app.route('/chk/', method="POST")
-def chk():
-    uri = request.forms.get('uri')
-    print uri
-    #result = "try chk"
-    result = _askCloud(cfg.APITYPE, uri)
-    return "/chk %s"% result
-
-@app.route('/ask/:uri')
-def ask(uri):
-    print uri
-    result = _askCloud(cfg.APITYPE, uri)
-    return "/ask %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)
-    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)])
-    else:
-        return result
-
-def __genQueryArgs(api_path, url):
-    args = {}
-    args["appkey"] = cfg.APPKEY
-    args["q"] = base64.urlsafe_b64encode(url)
-    args["timestamp"] = "%.3f" % (time.time())
-    sign_base_string = __genSignString(api_path, args)
-    args["sign"] = md5(sign_base_string + cfg.SECRET).hexdigest()
-    #print args, sign_base_string
-    return args
-    
-def __genSignString(api_path, args):
-    keys = args.keys()
-    keys.sort()
-    key_values = []
-    for k in keys:
-        v = args[k]
-        key_values.append("%s=%s" % (k, v))
-    base_string = api_path + "?" + "&".join(key_values)
-    return base_string
-
+def app(environ, start_response):
+    status = '200 OK'
+    response_headers = [('Content-type', 'text/plain')]
+    start_response(status, response_headers)
+    return ['Hollo, world!']
 
 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.