initial commit:

This commit is contained in:
2026-06-10 21:05:51 -05:00
commit 7f09944bf5
7 changed files with 96 additions and 0 deletions

9
api.py Normal file
View File

@@ -0,0 +1,9 @@
from flask import Flask
app = Flask("RecForever.API")
@app.route("/api")
def apiRoot():
pass
app.run(port=9902)

46
app.py Normal file
View File

@@ -0,0 +1,46 @@
import subprocess
import atexit
import sys
import time
trackedProcesses : list = []
def cleanup():
print("\n[MainServer] Cleaning up server processes")
for proc in trackedProcesses:
if proc.poll() is None:
print(f"[MainServer] Terming server subroutine {proc.pid}")
proc.terminate()
time.sleep(0.5)
for proc in trackedProcesses:
if proc.poll() is None:
print(f"[MainServer] Forcekilling leftover process {proc.pid}")
proc.kill()
atexit.register(cleanup)
def main():
try:
ns = subprocess.Popen([sys.executable, 'nameserver.py'])
trackedProcesses.append(ns)
api =subprocess.Popen([sys.executable, 'api.py'])
trackedProcesses.append(api)
auth =subprocess.Popen([sys.executable, 'auth.py'])
trackedProcesses.append(auth)
cdn =subprocess.Popen([sys.executable, 'cdn.py'])
trackedProcesses.append(cdn)
while True:
# make it run forever without doing anything (it should still output the individual servers outputs)
pass
except KeyboardInterrupt:
print("\n[MainServer] Server closing!")
finally:
sys.exit(0)
if __name__ == "__main__":
main()

15
auth.py Normal file
View File

@@ -0,0 +1,15 @@
from flask import Flask, request, jsonify
players = {
"Dev": "Dev123"
}
app = Flask("RecForever.Auth")
@app.route("/login/byuid", methods=['POST'])
def login():
data = request.get_json()
username = data.get('username')
password = data.get('password')
if players[username] == password:
return jsonify({"status": "ok"}), 200
else:
return jsonify({"status": "forbidden"}), 403
app.run(port=9904)

17
cdn.py Normal file
View File

@@ -0,0 +1,17 @@
import http.server
import socketserver
import functools
port = 9903
db = "db"
Handler = functools.partial(
http.server.SimpleHTTPRequestHandler,
directory=db
)
with socketserver.TCPServer(("", port), Handler) as httpd:
try:
httpd.serve_forever()
except KeyboardInterrupt:
httpd.server_close()

BIN
db/images/person.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
db/spaces/DormRoom.scn Normal file

Binary file not shown.

9
nameserver.py Normal file
View File

@@ -0,0 +1,9 @@
from flask import Flask, make_response, jsonify
app = Flask("RecForever.NamerServer")
@app.route("/")
def root():
return jsonify({"api": "127.0.0.1:9902", "cdn": "127.0.0.1:9903", "auth": "127.0.0.1:9904"})
app.run(port=9901)