You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.4 KiB

6 years ago
  1. from flask import Flask, send_from_directory
  2. from flask_restful import Api
  3. from flask_cors import CORS, cross_origin
  4. from modules import user_info, voting_system, rating_system, denunciation, announcements, complaint, car_crash, smart_park,navigation,bus_stops
  5. from modules import utility
  6. app = Flask(__name__)
  7. api = Api(app)
  8. app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog'
  9. app.config['CORS_HEADERS'] = 'Content-Type'
  10. cors = CORS(app, resources={r"/foo": {"origins": "*"}})\
  11. @app.route('/img/<path:path>')
  12. def send_img(path):
  13. return send_from_directory('images', path)
  14. if __name__ == '__main__':
  15. context = ('encryption/mycity.crt', 'encryption/mycity-decrypted.key')
  16. api.add_resource(voting_system.Votings, '/votings', '/votings/')
  17. api.add_resource(voting_system.Voting, '/votings/<int:voting_id>')
  18. api.add_resource(voting_system.Vote, '/vote', '/vote/')
  19. api.add_resource(rating_system.Ratings, '/ratings', '/ratings/')
  20. api.add_resource(rating_system.Rating, '/ratings/<int:rating_id>', '/ratings/<int:rating_id>/')
  21. api.add_resource(rating_system.Rate, '/rate', '/rate/')
  22. api.add_resource(user_info.Users, '/users', '/users/')
  23. api.add_resource(user_info.User, '/users/<path:user_id>', '/users/<path:user_id>/')
  24. api.add_resource(user_info.Login, '/login', '/login/')
  25. api.add_resource(user_info.Image, '/img', '/img/')
  26. api.add_resource(user_info.ReducePoints, '/reduce', '/reduce/')
  27. # api.add_resource(utility.Resources, '/resources', '/resources/')
  28. api.add_resource(denunciation.Alert, '/denunciation', '/denunciation/')
  29. api.add_resource(denunciation.Denunciations, '/denunciations', '/denunciations/')
  30. api.add_resource(navigation.Transit, '/transit', '/transit/')
  31. api.add_resource(bus_stops.Bus, '/bus', '/bus/')
  32. api.add_resource(announcements.Announcement, '/announcements', '/announcements/')
  33. api.add_resource(smart_park.Empty, '/parking', '/parking/')
  34. api.add_resource(complaint.Complaint,"/complaint","/complaint/")
  35. api.add_resource(complaint.Complaints,"/complaints","/complaints/")
  36. api.add_resource(complaint.ComplaintsUpdate,"/complaints_update","/complaints_update/")
  37. api.add_resource(car_crash.Crash, '/crash', '/crash/')
  38. api.add_resource(car_crash.Crashes, '/crashes', '/crashes/')
  39. app.run(host='0.0.0.0', port=5000, ssl_context=context, debug=True)