资源简介

公交查询系统源码(JAVA),可直接运行。做毕业设计、课程设计或者想研究下技术的可以下载学习。

资源截图

代码片段和文件信息

#-*-coding:utf-8-*-  
#qpy:webapp:公交路线查询
#qpy:fullscreen
#qpy://127.0.0.1:8081/
“““
公交路线查询

@Author river
“““

from bottle import Bottle ServerAdapter
from bottle import run debug route error static_file template redirect request

import urllib2
import os
import json
#### 常量定义 #########
ASSETS = “/assets/“
ROOT = os.path.dirname(os.path.abspath(__file__))

API_URL = ‘http://openapi.aibang.com/bus/lines?app_key=d706b1f36e6adfdb862f7f54c132390f&alt=json‘
API_URL2 = ‘http://openapi.aibang.com/bus/transfer?app_key=d706b1f36e6adfdb862f7f54c132390f&alt=json‘

######### QPYTHON WEB SERVER ###############

class MyWSGIRefServer(ServerAdapter):
    server = None

    def run(self handler):
        from wsgiref.simple_server import make_server WSGIRequestHandler
        if self.quiet:
            class QuietHandler(WSGIRequestHandler):
                def log_request(*args **kw): pass
            self.options[‘handler_class‘] = QuietHandler
        self.server = make_server(self.host self.port handler **self.options)
        self.server.serve_forever()

    def stop(self):
        #sys.stderr.close()
        import threading 
        threading.Thread(target=self.server.shutdown).start() 
        #self.server.shutdown()
        self.server.server_close() 
        print “# QWEBAPPEND“


######### BUILT-IN ROUTERS ###############
def __exit():
    global server
    server.stop()

def __ping():
    return “ok“

def server_static(filepath):
    return static_file(filepath root=ROOT+‘/assets‘)

def home():
    return template(ROOT+‘/index.html‘)

def detail():
    city = request.GET[‘city‘]
    q = request.GET[‘keyword‘]

    data = _get_json_content(API_URL+“&city=“+city+“&q=“+q)

    return template(ROOT+‘/detail.html‘ data=data)

def transfer():
    city = request.GET[‘city‘]
    here = request.GET[‘here‘]
    ther = request.GET[‘ther‘]

    data = _get_json_content(API_URL2+“&city=“+city+“&start_addr=“+here+“&end_addr=“+ther)
    print data
    return template(ROOT+‘/transfer.html‘data=data)

def _get_json_content(jurl):
    print jurl
    data = urllib2.urlopen(jurl)
    content = data.read()
    data.close()
    
    return content




######### WEBAPP ROUTERS ###############
app = Bottle()
app.route(‘/‘ method=‘GET‘)(home)
app.route(‘/detail‘ method=‘GET‘)(detail)
app.route(‘/transfer‘ method=‘GET‘)(transfer)
app.route(‘/__exit‘ method=[‘GET‘‘HEAD‘])(__exit)
app.route(‘/__ping‘ method=[‘GET‘‘HEAD‘])(__ping)
app.route(‘/assets/‘ method=‘GET‘)(server_static)

try:
    server = MyWSGIRefServer(host=“127.0.0.1“ port=“8081“)
    app.run(server=serverreloader=False)
except Exceptionex:
    print “Exception: %s“ % repr(ex)



 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-12-14 09:07  BusHelper-master\
     文件         702  2015-12-14 09:07  BusHelper-master\.gitignore
     文件        6931  2015-12-14 09:07  BusHelper-master\INTRO.md
     文件        1080  2015-12-14 09:07  BusHelper-master\LICENSE
     文件          74  2015-12-14 09:07  BusHelper-master\README.md
     目录           0  2015-12-14 09:07  BusHelper-master\src\
     目录           0  2015-12-14 09:07  BusHelper-master\src\assets\
     目录           0  2015-12-14 09:07  BusHelper-master\src\assets\css\
     文件      254729  2015-12-14 09:07  BusHelper-master\src\assets\css\amazeui.min.css
     目录           0  2015-12-14 09:07  BusHelper-master\src\assets\fonts\
     文件       71508  2015-12-14 09:07  BusHelper-master\src\assets\fonts\fontawesome-webfont.woff
     目录           0  2015-12-14 09:07  BusHelper-master\src\assets\js\
     文件      218956  2015-12-14 09:07  BusHelper-master\src\assets\js\amazeui.min.js
     文件       84245  2015-12-14 09:07  BusHelper-master\src\assets\js\jquery.min.js
     文件           0  2015-12-14 09:07  BusHelper-master\src\assets\test
     文件        2101  2015-12-14 09:07  BusHelper-master\src\detail.html
     文件        5112  2015-12-14 09:07  BusHelper-master\src\index.html
     文件        2732  2015-12-14 09:07  BusHelper-master\src\main.py
     文件        2682  2015-12-14 09:07  BusHelper-master\src\transfer.html

评论

共有 条评论