Browse Source

Merge remote-tracking branch 'origin/efe' into yigit

old
Yiğit Çolakoğlu 6 years ago
parent
commit
d05ff0f2f1
3 changed files with 37 additions and 0 deletions
  1. +1
    -0
      server_side/api/app.py
  2. +11
    -0
      server_side/api/modules/databases/denunciations.json
  3. +25
    -0
      server_side/api/modules/denunciation.py

+ 1
- 0
server_side/api/app.py View File

@ -28,6 +28,7 @@ if __name__ == '__main__':
api.add_resource(utility.Resources, '/resources', '/resources/')
api.add_resource(denunciation.Alert, '/denunciation', '/denunciation/')
api.add_resource(denunciation.Denounce, '/denounce', '/denounce/')
api.add_resource(navigation.Transit, '/transit', '/transit/')


+ 11
- 0
server_side/api/modules/databases/denunciations.json View File

@ -0,0 +1,11 @@
[
{
"reporter": "9vard12ty0ad2yvwp3q53rsf3h43r2vq",
"info": "There is a fire",
"priority": 8,
"location": {
"latitude": 39.9404,
"longitude": 32.9101
}
}
]

+ 25
- 0
server_side/api/modules/denunciation.py View File

@ -26,3 +26,28 @@ class Alert(Resource):
return {"success":True}
else:
return {"success":False,"penalty":"{}".format(100*(20-trust))}
class Denounce(Resource):
def post(self):
args = request.form
reporter = args['id']
denunciation_info = args['info']
denunciation_priority = args['priority']
denunciation_location = {
"latitude": args['latitude'],
"longitude": args['longitude']
}
denunciation = {
'reporter': reporter,
'info': denunciation_info,
'priority': denunciation_priority,
'location': denunciation_location
}
denunciations.append(denunciation)
with open(db_path, 'w') as f:
json.dump(denunciations, f, indent=4)
return denunciation

Loading…
Cancel
Save