mirror of
https://github.com/ApfelTeeSaft/HolyNetworking.git
synced 2026-08-26 19:23:34 +00:00
i don't know if this works, too drunk to test
This commit is contained in:
+94
@@ -0,0 +1,94 @@
|
||||
// TempleOS Account API Simulation
|
||||
|
||||
char username[32] := "apfelteesaft";
|
||||
char email[64] := "[email protected]";
|
||||
|
||||
void DatarouterResponse() {
|
||||
Print("204 No Content\n");
|
||||
}
|
||||
|
||||
void Token() {
|
||||
// simulate token response lol
|
||||
Print("Token Granted\nAccess Token: eg1~h1e35h4tr5h456r4h75r4h8r4h5r45h4r5\n");
|
||||
Print("Expires In: 28800\n");
|
||||
}
|
||||
|
||||
void ExternalAuths() {
|
||||
Print("External Auths Data\nProvider: example_provider\n");
|
||||
}
|
||||
|
||||
void Account() {
|
||||
Print("Account Info\n");
|
||||
Print("ID: 1234567890\nDisplayName: %s\nEmail: %s\n", username, email);
|
||||
}
|
||||
|
||||
void EnabledFeatures() {
|
||||
Print("Enabled Features:\nFeature1, Feature2, Feature3\n");
|
||||
}
|
||||
|
||||
void CloudStorage() {
|
||||
Print("Cloud Storage Data:\nStorage Item 1\nStorage Item 2\n");
|
||||
}
|
||||
|
||||
void Receipts() {
|
||||
Print("Receipts Data:\nReceipt ID: 001\nReceipt ID: 002\n");
|
||||
}
|
||||
|
||||
void Friends() {
|
||||
Print("Friends List:\nFriend1\nFriend2\n");
|
||||
}
|
||||
|
||||
void BlockList() {
|
||||
Print("Block List:\nBlockedUser1\nBlockedUser2\n");
|
||||
}
|
||||
|
||||
void VerifyAccount() {
|
||||
Print("Account Verification Status: Verified\n");
|
||||
}
|
||||
|
||||
void SetMtx() {
|
||||
Print("Set Mtx Transaction Successful\n");
|
||||
}
|
||||
|
||||
void QueryProfile() {
|
||||
Print("Profile Data:\nID: 001\nName: Sample Profile\n");
|
||||
}
|
||||
|
||||
void APIHandler() {
|
||||
ClrScr();
|
||||
Print("TempleOS Account API Backend\nListening for Routes...\n");
|
||||
|
||||
while (TRUE) {
|
||||
int key = KeyPeek();
|
||||
|
||||
if (key == '/') {
|
||||
KeyGet(); // Consume '/'
|
||||
int a = KeyGet();
|
||||
int p = KeyGet();
|
||||
int i = KeyGet();
|
||||
int slash = KeyGet();
|
||||
int r = KeyGet();
|
||||
int e = KeyGet();
|
||||
int s = KeyGet();
|
||||
int p2 = KeyGet();
|
||||
int o = KeyGet();
|
||||
int n = KeyGet();
|
||||
int s2 = KeyGet();
|
||||
int e2 = KeyGet();
|
||||
|
||||
if (a == 'a' && p == 'p' && i == 'i' && slash == '/' &&
|
||||
r == 'r' && e == 'e' && s == 's' && p2 == 'p' &&
|
||||
o == 'o' && n == 'n' && s2 == 's' && e2 == 'e') {
|
||||
|
||||
// This would call DatarouterResponse if "/api/response" is typed
|
||||
DatarouterResponse();
|
||||
Wait(100);
|
||||
return;
|
||||
}
|
||||
// other stuff, won't implement
|
||||
}
|
||||
Wait(1);
|
||||
}
|
||||
}
|
||||
|
||||
APIHandler();
|
||||
@@ -0,0 +1,42 @@
|
||||
from flask import Flask, jsonify
|
||||
import pyautogui
|
||||
import time
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def send_route_to_templeos(route):
|
||||
for char in route:
|
||||
pyautogui.press(char)
|
||||
pyautogui.press('enter')
|
||||
|
||||
def capture_response():
|
||||
response = []
|
||||
for _ in range(10):
|
||||
response.append(pyautogui.read_key())
|
||||
time.sleep(0.5)
|
||||
return ''.join(response)
|
||||
|
||||
|
||||
@app.route('/api/datarouter', methods=['GET'])
|
||||
def datarouter():
|
||||
route = "/api/response"
|
||||
send_route_to_templeos(route)
|
||||
result = capture_response()
|
||||
return jsonify({"result": result})
|
||||
|
||||
@app.route('/api/token', methods=['POST'])
|
||||
def token():
|
||||
route = "/api/token"
|
||||
send_route_to_templeos(route)
|
||||
result = capture_response()
|
||||
return jsonify({"result": result})
|
||||
|
||||
@app.route('/api/account', methods=['GET'])
|
||||
def account():
|
||||
route = "/api/account"
|
||||
send_route_to_templeos(route)
|
||||
result = capture_response()
|
||||
return jsonify({"result": result})
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(port=5000)
|
||||
Reference in New Issue
Block a user