apiServer.py 867 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # coding:utf-8
  2. '''
  3. 定义几个关键字,count type,protocol,country,area,
  4. '''
  5. import json
  6. import sys
  7. import web
  8. import config
  9. from db.DataStore import sqlhelper
  10. from db.SqlHelper import Proxy
  11. urls = (
  12. '/', 'select',
  13. '/delete', 'delete'
  14. )
  15. def start_api_server():
  16. sys.argv.append('0.0.0.0:%s' % config.API_PORT)
  17. app = web.application(urls, globals())
  18. app.run()
  19. class select(object):
  20. def GET(self):
  21. inputs = web.input()
  22. json_result = json.dumps(sqlhelper.select(inputs.get('count', None), inputs))
  23. return json_result
  24. class delete(object):
  25. params = {}
  26. def GET(self):
  27. inputs = web.input()
  28. json_result = json.dumps(sqlhelper.delete(inputs))
  29. return json_result
  30. if __name__ == '__main__':
  31. sys.argv.append('0.0.0.0:8000')
  32. app = web.application(urls, globals())
  33. app.run()