server.py 594 B

12345678910111213141516171819202122232425
  1. import connection
  2. import controller
  3. import model
  4. from bottle import run, request, response, route
  5. from controller import not_found
  6. if __name__ == '__main__':
  7. print('sqlite3.version', model.db.version)
  8. model.setup()
  9. valid_routes = ['login', 'register']
  10. @route('/<path>', method='POST')
  11. def process(path):
  12. if path not in valid_routes:
  13. return not_found()
  14. response.content_type = 'application/json'
  15. method_to_call = getattr(controller, path)
  16. return method_to_call()
  17. run(host='localhost', port=connection.port, debug=True)