offerpk3 commited on
Commit
58b257f
·
verified ·
1 Parent(s): 2ba6f7a

Update generator.py

Browse files
Files changed (1) hide show
  1. generator.py +34 -15
generator.py CHANGED
@@ -1,24 +1,43 @@
1
  def generate_app(prompt: str):
2
  print("🧠 Simulating Gemini API call...")
3
- return {
4
- "full_code": '''
5
- function App() {
6
- return <div>⚡ Hello, this is your generated app for: {prompt}</div>;
7
- }
8
- export default App;
9
- ''',
10
- "files": {
11
- "App.jsx": '''
12
- function App() {
13
- return <div>⚡ Hello, this is your generated app for: {prompt}</div>;
14
- }
15
  export default App;
16
  '''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
  }
19
 
20
  def enhance_app(existing_bundle: dict, enhancement_prompt: str):
21
- updated_code = existing_bundle["full_code"] + f"\\n// Enhancement applied: {enhancement_prompt}"
22
- existing_bundle["full_code"] = updated_code
23
- existing_bundle["files"]["App.jsx"] = updated_code
 
24
  return existing_bundle
 
1
  def generate_app(prompt: str):
2
  print("🧠 Simulating Gemini API call...")
3
+
4
+ jsx_code = f'''
5
+ function App() {{
6
+ return (
7
+ <div style={{ padding: "2rem", fontFamily: "sans-serif" }}>
8
+ <h1>Generated App</h1>
9
+ <p>This React app is based on your prompt: <strong>{prompt}</strong></p>
10
+ </div>
11
+ );
12
+ }}
 
 
13
  export default App;
14
  '''
15
+
16
+ index_html = '''
17
+ <!DOCTYPE html>
18
+ <html>
19
+ <head>
20
+ <meta charset="UTF-8" />
21
+ <title>Generated App</title>
22
+ </head>
23
+ <body>
24
+ <div id="root"></div>
25
+ <script type="module" src="./App.jsx"></script>
26
+ </body>
27
+ </html>
28
+ '''
29
+
30
+ return {
31
+ "full_code": jsx_code,
32
+ "files": {
33
+ "App.jsx": jsx_code,
34
+ "index.html": index_html
35
  }
36
  }
37
 
38
  def enhance_app(existing_bundle: dict, enhancement_prompt: str):
39
+ enhancement_note = f"// Enhancement: {enhancement_prompt}"
40
+ enhanced_code = enhancement_note + "\n" + existing_bundle["files"].get("App.jsx", "")
41
+ existing_bundle["files"]["App.jsx"] = enhanced_code
42
+ existing_bundle["full_code"] = enhanced_code
43
  return existing_bundle