Spaces:
Sleeping
Sleeping
File size: 1,574 Bytes
9625f38 96692cf 9625f38 a3830f2 96692cf 7cfe55a a88e1d8 7cfe55a a3830f2 7cfe55a a3830f2 6c5b86d 7cfe55a 9625f38 7cfe55a 96692cf a88e1d8 96692cf 9625f38 96692cf a88e1d8 96692cf 9625f38 3eb99bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# portfolio/app.py
from flask import Flask, render_template, url_for, redirect
from npc_social_network.routes.npc_route import npc_bp
# from stock.routes.stock_route import stock_bp
import os
import subprocess
# ์๋ฎฌ๋ ์ด์
ํ๋ก์ธ์ค๋ฅผ ๊ด๋ฆฌํ ์ ์ญ ๋ณ์
simulation_process = None
def create_app():
app = Flask(__name__) # static/template ๊ฒฝ๋ก๋ฅผ ๊ธฐ๋ณธ๊ฐ
# ๊ฐ ํ๋ก์ ํธ๋ Blueprint์์ ์๊ธฐ static/template ๊ด๋ฆฌ
app.register_blueprint(npc_bp)
# app.register_blueprint(stock_bp)
@app.route("/")
def index():
return render_template("main.html")
@app.route("/run_npc_simulation")
def run_npc_simulation():
global simulation_process
# ์ด๋ฏธ ์คํ ์ค์ธ ํ๋ก์ธ์ค๊ฐ ์๋ค๋ฉด ์ข
๋ฃ
if simulation_process and simulation_process.poll() is None:
simulation_process.terminate()
simulation_process.wait()
# ํ์ด์ฌ ๊ฐ์ํ๊ฒฝ์ ์คํ ํ์ผ ๊ฒฝ๋ก๋ฅผ ๋ช
์์ ์ผ๋ก ์ง์ ํ ์ ์์
python_exec = "python"
# ๋น๋๊ธฐ๋ก Pygame ์๋ฎฌ๋ ์ด์
์คํ
subprocess.Popen([python_exec, "-m", "npc_social_network.maps.villages.town_hall"]) # ๋น๋๊ธฐ๋ก ์คํ (์ฐฝ ๋์)
# ์คํ ํ ์ฌ์ฉ์ ์๋ด ํ์ด์ง ํ์
return redirect(url_for('npc_social.home'))
return app
if __name__ == '__main__':
app = create_app()
print("[MAIN] Starting Flask app only (Background NPC interactions handled by separate runner).", flush=True)
app.run(debug=True, use_reloader=False) |