From 2780072a278fa5128cf961284e5c04312d5e6119 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Mon, 30 Jun 2025 20:55:53 +0800 Subject: initial commit --- backend/ai-vision.py | 48 ++++++++++++++++++ backend/ai.py | 8 +++ backend/alvl.jpg | Bin 0 -> 107082 bytes backend/game_simpliCity_main.png | Bin 0 -> 1522731 bytes ...ouble-VariableFont_CRSV,ELSH,ELXP,slnt,wght.ttf | Bin 0 -> 162000 bytes frontend/index.html | 21 ++++++++ frontend/script.js | 56 +++++++++++++++++++++ 7 files changed, 133 insertions(+) create mode 100644 backend/ai-vision.py create mode 100644 backend/ai.py create mode 100644 backend/alvl.jpg create mode 100644 backend/game_simpliCity_main.png create mode 100644 frontend/BitcountGridDouble-VariableFont_CRSV,ELSH,ELXP,slnt,wght.ttf create mode 100644 frontend/index.html create mode 100644 frontend/script.js diff --git a/backend/ai-vision.py b/backend/ai-vision.py new file mode 100644 index 0000000..866bcb8 --- /dev/null +++ b/backend/ai-vision.py @@ -0,0 +1,48 @@ +from google import genai +from google.genai import types +import flask +import flask_cors + +app = flask.Flask(__name__) +flask_cors.CORS(app) + +UPLOAD_FOLDER = "uploads" +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + +client = genai.Client(api_key="AIzaSyA-mA7v4xlbEAz80uKf3Dywpbeh9ZfpLMs") + + +@app.route("/yeah", methods=["POST"]) +def yeah_flask(): + uploaded_files = flask.request.files.getlist("files") + + file_names = [] + + contents = [] + + for file in uploaded_files: + file_data = file.read() + print(file.filename) + file_names.append(file.filename) + contents.append( + types.Part.from_bytes( + data=file_data, + mime_type=file.mimetype + ) + ) + + contents.append("Please summarise the following content make it concise but detailed, organised into a mind map, structured with clear hierarchy, where each item is first prefixed and just prefixed with a > times depth, where depth starts at 1. For example, a sub item would be \">> subitem\". Do not start or end your message with an approval message, start immediately with the content requested. Absolutely do not add any blank lines, and do not add spaces after the '>' prefix. Do not add numbers after the '>' prefix.") + + response = client.models.generate_content( + model="gemini-2.0-flash", + contents=contents + ) + + print(response) + + print("hi") + return flask.jsonify({"status": "success", "map": response.text}) + + +if __name__ == '__main__': + app.run(debug=True, host='127.0.0.1', port=9000) diff --git a/backend/ai.py b/backend/ai.py new file mode 100644 index 0000000..1e63b94 --- /dev/null +++ b/backend/ai.py @@ -0,0 +1,8 @@ +from google import genai + +client = genai.Client(api_key="AIzaSyA-mA7v4xlbEAz80uKf3Dywpbeh9ZfpLMs") + +response = client.models.generate_content( + model="gemini-2.0-flash", contents="Explain how AI works in a few words" +) +print(response.text) diff --git a/backend/alvl.jpg b/backend/alvl.jpg new file mode 100644 index 0000000..cd35987 Binary files /dev/null and b/backend/alvl.jpg differ diff --git a/backend/game_simpliCity_main.png b/backend/game_simpliCity_main.png new file mode 100644 index 0000000..e31067c Binary files /dev/null and b/backend/game_simpliCity_main.png differ diff --git a/frontend/BitcountGridDouble-VariableFont_CRSV,ELSH,ELXP,slnt,wght.ttf b/frontend/BitcountGridDouble-VariableFont_CRSV,ELSH,ELXP,slnt,wght.ttf new file mode 100644 index 0000000..78fd014 Binary files /dev/null and b/frontend/BitcountGridDouble-VariableFont_CRSV,ELSH,ELXP,slnt,wght.ttf differ diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..c9ef360 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,21 @@ + + + + + mindmap.ai + + + + + + + +

mindmap.ai

+ + + +
+ + diff --git a/frontend/script.js b/frontend/script.js new file mode 100644 index 0000000..5af0c08 --- /dev/null +++ b/frontend/script.js @@ -0,0 +1,56 @@ +document.addEventListener('DOMContentLoaded', () => { + const fileInput = document.getElementById('file-input'); + const fileList = document.getElementById('file-list'); + const btn = document.getElementById('doit-btn'); + const cont = document.getElementById('mindmap'); + + var files; + + fileInput.addEventListener('change', (event) => { + fileList.innerHTML = ""; + + files = event.target.files; + + for (let i = 0; i < files.length; i++) { + fileList.innerHTML += `
  • ${files[i].name}
  • `; + } + }); + + btn.addEventListener('click', async () => { + if (files.length == 0) return; + + const formData = new FormData(); + + for (let i = 0; i < files.length; i++) { + formData.append('files', files[i]); + } + + cont.innerHTML = "Generating..."; + + const response = await fetch("http://127.0.0.1:9000/yeah", { + method: "POST", + body: formData + }) + + + const data = await response.json(); + + lines = data.map.split('\n') + + cont.innerHTML = ""; + + for (let i = 0; i < lines.length; i++) { + if (lines.length == 0) return; + + let depth = 0; + for (let j = 0; j < lines[i].length; j++) { + if (lines[i][j] == ">") { + depth++; + } else {break;} + } +console.log(lines[i].slice(depth, lines[i].length)) + cont.innerHTML += `
    ${lines[i].slice(depth, lines[i].length)}
    `; + console.log(cont.innerHTML); + } + }); +}); -- cgit v1.2.3