Skip to content

Commit

Permalink
stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinedaa committed Jun 22, 2024
1 parent 0bc6f84 commit 87ef6f4
Show file tree
Hide file tree
Showing 8 changed files with 593,393 additions and 27 deletions.
18 changes: 0 additions & 18 deletions Narravive.bat

This file was deleted.

11 changes: 6 additions & 5 deletions backend/app.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

block_cipher = None

a = Analysis(['server.py'],
a = Analysis(['entry_point.py'],
pathex=['.'],
binaries=[],
datas=[('./state', './state'), ('./prompts', './prompts')],
datas=[('./state', './state'), ('./prompts', './prompts'), ('./frontend', './frontend')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
Expand All @@ -23,14 +23,15 @@ exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='narravive_server',
name='Narravive',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False )
console=False,
icon='./app_icon.ico')

coll = COLLECT(exe,
a.binaries,
Expand All @@ -39,4 +40,4 @@ coll = COLLECT(exe,
strip=False,
upx=True,
upx_exclude=[],
name='narravive_server')
name='Narravive')
Binary file added backend/app_icon.ico
Binary file not shown.
44 changes: 44 additions & 0 deletions backend/entry_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import threading
import time
import requests
import subprocess
import os
from server import app


def run_flask_app():
app.run(port=5000) # Ensure this matches your Flask server's settings


def check_server():
"""Check server status."""
try:
response = requests.get("http://localhost:5000/health")
return response.status_code == 200
except requests.ConnectionError:
return False


def start_frontend():
current_dir = os.path.dirname(os.path.abspath(__file__))
frontend_path = os.path.join(current_dir, "frontend/narravive.exe")
print(f"Starting frontend at {frontend_path}")
subprocess.call([frontend_path])


def main():
# Start Flask app in a separate thread
threading.Thread(target=run_flask_app, daemon=True).start()
print("Server is starting...")

# Wait for the server to be ready
while not check_server():
print("Waiting for server to be ready...")
time.sleep(1)

print("Server is ready.")
start_frontend()


if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def save_game_state(game_state, file_path):
file.write(json_string)


@app.route('/health')
def health():
return "OK", 200


@app.route('/gamestate', methods=['GET'])
def get_game_state():
file_path = request.args.get('path', '')
Expand Down
Loading

0 comments on commit 87ef6f4

Please sign in to comment.