File size: 1,173 Bytes
2a1cdbf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from utils.summarizer import summarize_code
from utils.doc_generator import generate_document, generate_pptx
import os

st.title("πŸ“„ Code to Project Document Generator")
st.write("Upload your code files and a headings.txt file.")

uploaded_files = st.file_uploader("Upload code files (Python/React)", accept_multiple_files=True)
headings_file = st.file_uploader("Upload headings.txt", type="txt")

if st.button("Generate Document") and uploaded_files and headings_file:
    with open("headings.txt", "wb") as f:
        f.write(headings_file.read())

    code_dir = "uploaded_code"
    os.makedirs(code_dir, exist_ok=True)

    for file in uploaded_files:
        with open(os.path.join(code_dir, file.name), "wb") as f:
            f.write(file.read())

    sections = summarize_code(code_dir, "headings.txt")
    generate_document(sections)
    generate_pptx(sections)

    st.success("Documents generated!")
    st.download_button("Download DOCX", data=open("project_report.docx", "rb"), file_name="project_report.docx")
    st.download_button("Download PPTX", data=open("project_presentation.pptx", "rb"), file_name="project_presentation.pptx")