-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
41 lines (33 loc) · 1.08 KB
/
Copy pathapp.py
File metadata and controls
41 lines (33 loc) · 1.08 KB
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
from flask import Flask, render_template, request, jsonify
from iching_core.hexagram_generator import HexagramGenerator
from iching_core.hexagram_analyzer import HexagramAnalyzer
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/result')
def result():
return render_template('result.html')
@app.route('/analyze', methods=['POST'])
def analyze():
try:
data = request.get_json()
topic = data.get('topic', '')
template = data.get('template', 'traditional')
# 生成卦象
generator = HexagramGenerator()
hexagram = generator.generate_hexagram(topic)
# 分析卦象
analyzer = HexagramAnalyzer(hexagram)
analysis_result = analyzer.generate_analysis()
return jsonify({
'success': True,
'result': analysis_result
})
except Exception as e:
return jsonify({
'success': False,
'error': str(e)
}), 500
if __name__ == '__main__':
app.run(debug=True, port=5000)