Aigg / app.py
Athspi's picture
Update app.py
e4cd3fb verified
raw
history blame
1.23 kB
from flask import Flask, render_template, request, session, redirect, url_for
import os
from flask_session import Session
app = Flask(__name__)
app.secret_key = 'supersecretkey'
app.config['SESSION_TYPE'] = 'filesystem'
Session(app)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/chat', methods=['GET', 'POST'])
def chat():
# Simulate chat history
if 'chat_history' not in session:
session['chat_history'] = []
if 'project_tree' not in session:
session['project_tree'] = ['main.py', 'requirements.txt', 'templates/index.html']
ai_reply = ''
if request.method == 'POST':
user_message = request.form.get('user_message')
ai_reply = "Simulated AI response to: " + user_message
session['chat_history'].append({'user': user_message, 'ai': ai_reply})
return render_template('chat.html',
chat_history=session.get('chat_history', []),
project_tree=session.get('project_tree', []),
ai_reply=ai_reply)
@app.route('/download_project')
def download_project():
return "Simulated download"
if __name__ == '__main__':
app.run(host="0.0.0.0", port=7860)