vectorplasticity commited on
Commit
dfd0cb7
·
verified ·
1 Parent(s): 09c09fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -2
app.py CHANGED
@@ -117,7 +117,38 @@ try:
117
 
118
  original_block = """ function uploadAndRender(formData) {
119
  statusDiv.textContent = "Analyzing entire project...";
120
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  replacement_block = """ function uploadAndRender(formData) {
123
  statusDiv.textContent = "Analyzing entire project...";
@@ -252,7 +283,7 @@ def upload_project():
252
  os.makedirs(os.path.dirname(abs_path), exist_ok=True)
253
  file.save(abs_path)
254
  elif 'http' in request.form.get('repo-input'):
255
- http=request.form.get('repo-input')
256
  print('http found')
257
  print(http)
258
  zip_repo=f'{http}/archive/refs/heads/main.zip'
 
117
 
118
  original_block = """ function uploadAndRender(formData) {
119
  statusDiv.textContent = "Analyzing entire project...";
120
+ loader.style.display = 'flex';
121
+ fetch('/upload', { method: 'POST', body: formData })
122
+ .then(res => res.ok ? res.json() : Promise.reject(res))
123
+ .then(data => {
124
+ if (data.error) throw new Error(data.error);
125
+ if (!data.fs_graph || data.fs_graph.nodes.length === 0) {
126
+ throw new Error("Analysis resulted in an empty graph. Please check the project structure.");
127
+ }
128
+ currentSessionId = data.sessionId;
129
+ fileSystemGraph = data.fs_graph;
130
+ searchMap = data.search_map;
131
+ currentGraphData = JSON.parse(JSON.stringify(fileSystemGraph));
132
+ analysisControls.style.display = 'block';
133
+ statusDiv.textContent = "Analysis complete. Click a file to see its imports.";
134
+ populateSearchDatalist(searchMap);
135
+ updateGraph();
136
+ })
137
+ .catch(error => {
138
+ console.error("Caught an error:", error);
139
+ if (error && typeof error.json === 'function') {
140
+ error.json().then(errJson => {
141
+ statusDiv.textContent = `Error: ${errJson.error || 'Server error.'}`;
142
+ }).catch(() => {
143
+ statusDiv.textContent = 'Error: Could not parse server error response.';
144
+ });
145
+ } else {
146
+ statusDiv.textContent = `Error: ${error.message || 'Network request failed.'}`;
147
+ }
148
+ }).finally(() => {
149
+ loader.style.display = 'none';
150
+ });
151
+ }"""
152
 
153
  replacement_block = """ function uploadAndRender(formData) {
154
  statusDiv.textContent = "Analyzing entire project...";
 
283
  os.makedirs(os.path.dirname(abs_path), exist_ok=True)
284
  file.save(abs_path)
285
  elif 'http' in request.form.get('repo-input'):
286
+ http=Path(request.form.get('repo-input'))
287
  print('http found')
288
  print(http)
289
  zip_repo=f'{http}/archive/refs/heads/main.zip'