CORVO-AI commited on
Commit
f693015
·
verified ·
1 Parent(s): a8187b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -7,7 +7,7 @@ app = Flask(__name__)
7
 
8
  # Step 1: Fetch the authenticity_token and commitOid from the GitHub edit page
9
  def fetch_authenticity_token_and_commit_oid():
10
- url = "https://github.com/omarnuwrar/api/edit/main/user.json"
11
 
12
  headers = {
13
  "cookie": "_octo=GH1.1.1509769180.1721774314; _device_id=0038e28d4f7d4f9baf8f76b6b9fb8980; saved_user_sessions=155741452%3Avhq2fotRhM6ixLZuU8plCTagdBxOI9UGuu5XwPf569UWHPOg; user_session=vhq2fotRhM6ixLZuU8plCTagdBxOI9UGuu5XwPf569UWHPOg; __Host-user_session_same_site=vhq2fotRhM6ixLZuU8plCTagdBxOI9UGuu5XwPf569UWHPOg; logged_in=yes; dotcom_user=omarnuwrar; color_mode=%7B%22color_mode%22%3A%22auto%22%2C%22light_theme%22%3A%7B%22name%22%3A%22light%22%2C%22color_mode%22%3A%22light%22%7D%2C%22dark_theme%22%3A%7B%22name%22%3A%22dark%22%2C%22color_mode%22%3A%22dark%22%7D%7D; cpu_bucket=lg; preferred_color_mode=light; tz=Africa%2FTripoli; _gh_sess=cmT9%2BKjq2RkmHF1yGIv0U25vE58ydhCtNe9GK26HxTEojhfvyQXwn0HhD1dCMQkEI5eXOA8kQm8EmM11JtSkNlpW7yECoyPnWUDBAOkHKNovsRrJ%2FpAAGM7zmYrs3kJNQXWIKGPN1jW8Hb3%2FPyMIH74N7k1sGKXq1CTjvi%2BSPofDjCF3%2BNdgTM1G7OPwV%2Fuu%2FB1%2FOro05an8u8%2BWppVww4A0GWiczmOk8g1xlczsgc8LVTb2R5hY%2FVz1exXbVJ6TFGuRpIGs2%2BuD3%2BSWCTHVWyw7%2By1b5f3V8MU5Jmg5UWdnW5B9%2FjW17dAosAYpD1vGuGj8tgi2hLUTzuDdpwVIplBzjUpw0cWL%2BJPpXZ4LWo2H71vPQv8VgQS3WUTxUfkF4UM6Sagdk41EgK4HjS0Ebb8%2BXF3uMNXQXvVcHbGMPGlUX%2BuVmwOf0zO9Ne0y63o09yojQQ74H1oDYwluyJkbX0XqB5RYA6A3AabUTYoL%2B2gPG4maWamZ7DlLShj0bfruQ563GrZwM3tbHpFk8aeJaqWLLwQTXh2o7f5IJhj3qtgwv%2BfxbzrrpXNzhy7iuWlkFKKgQOTG1yrj1ho%2B1wec6hCzFekh%2BVmuHdlOo0opAvTM4aTydsvr0XoW9NXn9z2IGr27K6M7632bJiET2I6sXa8dAKQeWCvXRJt7HDxHayLs3NDJKYAhjOCii%2FLHja7Yksxuxvo3OL1LQw9aNAanjTYOgK5oXT5pC3Q5EKtb1NSrpEo%2ByzNgpFHEp3%2FzvtzEratIK4Jg0jWoasL2hlMpvgQQuLX3NAQhPuXKFfgG2AqkR%2BSlwVw8AVrjVJ6w4AeWVyD1fjq3GkWmKP7yELjLIYGMdNzIVxwmTysLhoFfAv%2BnpM%2B5--iM2WECPbjmZsWX3j--%2FXZDhW0%2FhViqIiMx%2FzhPiQ%3D%3D",
@@ -27,7 +27,7 @@ def fetch_authenticity_token_and_commit_oid():
27
  if script_tag:
28
  try:
29
  json_data = json.loads(script_tag.string.strip())
30
- authenticity_token = json_data["payload"]["csrf_tokens"]["/omarnuwrar/api/tree-save/main/user.json"]["post"]
31
  commit_oid = json_data["payload"]["webCommitInfo"]["commitOid"]
32
  return authenticity_token, commit_oid
33
  except (KeyError, json.JSONDecodeError) as e:
@@ -42,7 +42,7 @@ def fetch_authenticity_token_and_commit_oid():
42
 
43
  # Step 2: Send the POST request to update the user.json file
44
  def update_user_json_file(authenticity_token, commit_oid, new_content):
45
- url = "https://github.com/omarnuwrar/api/tree-save/main/user.json"
46
 
47
  headers = {
48
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
@@ -53,8 +53,8 @@ def update_user_json_file(authenticity_token, commit_oid, new_content):
53
  }
54
 
55
  payload = {
56
- "message": "Update user.json",
57
- "placeholder_message": "Update user.json",
58
  "description": "",
59
  "commit-choice": "direct",
60
  "target_branch": "main",
@@ -64,7 +64,7 @@ def update_user_json_file(authenticity_token, commit_oid, new_content):
64
  "same_repo": "1",
65
  "pr": "",
66
  "content_changed": "true",
67
- "filename": "user.json",
68
  "new_filename": "user.json",
69
  "value": new_content,
70
  "authenticity_token": authenticity_token,
@@ -82,7 +82,7 @@ def update_user_json_file(authenticity_token, commit_oid, new_content):
82
  # Function to fetch and extract the JSON data
83
  def fetch_json_from_github():
84
  # URL of the GitHub page
85
- url = "https://github.com/omarnuwrar/api/blob/main/user.json"
86
 
87
  # Custom headers
88
  headers = {
@@ -126,7 +126,7 @@ def fetch_json_from_github():
126
 
127
 
128
 
129
- @app.route('/read_user_json', methods=['GET'])
130
  def fetch_user_json():
131
  result = fetch_json_from_github()
132
  return jsonify(result)
@@ -134,7 +134,7 @@ def fetch_user_json():
134
 
135
 
136
  # API Endpoint to update user.json
137
- @app.route('/update_user_json', methods=['POST'])
138
  def update_user_json():
139
  data = request.json
140
 
 
7
 
8
  # Step 1: Fetch the authenticity_token and commitOid from the GitHub edit page
9
  def fetch_authenticity_token_and_commit_oid():
10
+ url = "https://github.com/omarnuwrar/api/edit/main/Septimius.json"
11
 
12
  headers = {
13
  "cookie": "_octo=GH1.1.1509769180.1721774314; _device_id=0038e28d4f7d4f9baf8f76b6b9fb8980; saved_user_sessions=155741452%3Avhq2fotRhM6ixLZuU8plCTagdBxOI9UGuu5XwPf569UWHPOg; user_session=vhq2fotRhM6ixLZuU8plCTagdBxOI9UGuu5XwPf569UWHPOg; __Host-user_session_same_site=vhq2fotRhM6ixLZuU8plCTagdBxOI9UGuu5XwPf569UWHPOg; logged_in=yes; dotcom_user=omarnuwrar; color_mode=%7B%22color_mode%22%3A%22auto%22%2C%22light_theme%22%3A%7B%22name%22%3A%22light%22%2C%22color_mode%22%3A%22light%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DhW0%2FhViqIiMx%2FzhPiQ%3D%3D",
 
27
  if script_tag:
28
  try:
29
  json_data = json.loads(script_tag.string.strip())
30
+ authenticity_token = json_data["payload"]["csrf_tokens"]["/omarnuwrar/api/tree-save/main/Septimius.json"]["post"]
31
  commit_oid = json_data["payload"]["webCommitInfo"]["commitOid"]
32
  return authenticity_token, commit_oid
33
  except (KeyError, json.JSONDecodeError) as e:
 
42
 
43
  # Step 2: Send the POST request to update the user.json file
44
  def update_user_json_file(authenticity_token, commit_oid, new_content):
45
+ url = "https://github.com/omarnuwrar/api/tree-save/main/Septimius.json"
46
 
47
  headers = {
48
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
 
53
  }
54
 
55
  payload = {
56
+ "message": "Update Septimius.json",
57
+ "placeholder_message": "Update Septimius.json",
58
  "description": "",
59
  "commit-choice": "direct",
60
  "target_branch": "main",
 
64
  "same_repo": "1",
65
  "pr": "",
66
  "content_changed": "true",
67
+ "filename": "Septimius.json",
68
  "new_filename": "user.json",
69
  "value": new_content,
70
  "authenticity_token": authenticity_token,
 
82
  # Function to fetch and extract the JSON data
83
  def fetch_json_from_github():
84
  # URL of the GitHub page
85
+ url = "https://github.com/omarnuwrar/api/blob/main/Septimius.json"
86
 
87
  # Custom headers
88
  headers = {
 
126
 
127
 
128
 
129
+ @app.route('/read_Septimius_json', methods=['GET'])
130
  def fetch_user_json():
131
  result = fetch_json_from_github()
132
  return jsonify(result)
 
134
 
135
 
136
  # API Endpoint to update user.json
137
+ @app.route('/update_Septimius_json', methods=['POST'])
138
  def update_user_json():
139
  data = request.json
140