Advertisement
Hygcgggnngff

backend summersplash

Sep 28th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. from flask import Flask, request, jsonify # Added missing imports
  2. import requests
  3. import json
  4. import hashlib
  5. import os
  6. from datetime import datetime
  7.  
  8. app = Flask(__name__)
  9.  
  10. webhookUrl = "https://discord.com/api/webhooks/1153559821266722836/QbJlR7xfvcPndTN76NUatcFVENddx14gEEOw1iM9jMOI4DONXuwJFUfWyy_-8EYQF_63"
  11. webhookUrl2 = "https://discord.com/api/webhooks/1153559821266722836/QbJlR7xfvcPndTN76NUatcFVENddx14gEEOw1iM9jMOI4DONXuwJFUfWyy_-8EYQF_63"
  12.  
  13. def loadTitleDataFromFile():
  14. try:
  15. with open('titleData.json', 'r') as file:
  16. return json.load(file)
  17. except Exception as e:
  18. print(e)
  19. return {}
  20.  
  21. def saveTitleDataToFile(data):
  22. with open('titleData.json', 'w') as file:
  23. json.dump(data, file, indent=2)
  24.  
  25. def md5(data):
  26. return hashlib.md5(data.encode('utf-8')).hexdigest()
  27.  
  28. @app.route('/', methods=['GET'])
  29. def get_title_data():
  30. global titleData
  31. print('Title data fetched: ', titleData)
  32. return jsonify(titleData)
  33.  
  34. @app.route('/', methods=['POST'])
  35. def update_title_data():
  36. global titleData
  37. receivedData = request.json['data']
  38. titleData = receivedData
  39. saveTitleDataToFile(titleData)
  40. return jsonify({"message": "Data updated successfully"})
  41. def get_user_id(ticket):
  42. filtered_id = ticket[:16].replace("'", "")
  43. filtered_id2 = filtered_id.replace("-", "")
  44. filtered_id3 = filtered_id2.replace(".", "")
  45. return filtered_id3
  46. @app.route('/api/photon', methods=['POST'])
  47. def photon_api():
  48. data = request.json
  49. user_id = get_user_id(data['Ticket'])
  50. data["UserId"] = user_id
  51. app = data['AppId']
  52. if app != '9D0DF':
  53. return jsonify({'status': 'error', 'message': 'Unauthorized AppId'})
  54. if "Nonce" in data:
  55. nonce = data["Nonce"]
  56. else:
  57. nonce = "EMPTY"
  58. returndata = { # Define returndata outside the if/else block
  59. "ResultCode": 1,
  60. "StatusCode": 200,
  61. "Message": '',
  62. "result": 0,
  63. "UserId": user_id,
  64. "AppId": "9D0DF",
  65. "Ticket": data['Ticket'],
  66. "Token": data['Token'],
  67. "Nonce": nonce
  68. }
  69.  
  70. return jsonify(returndata)
  71.  
  72. if __name__ == "__main__":
  73. app.run()
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement