Saturday, 26 July 2025

Bio data

import string import random from flask import Flask, request, redirect, render_template_string app = Flask(__name__) bio_data_storage = {} def generate_short_code(length=6): return ''.join(random.choices(string.ascii_letters + string.digits, k=length)) form_html = """

Biodata Form

Name:
Age:
Skills:
{% if short_url %}

Your short link: {{ short_url }}

{% endif %} """ @app.route("/", methods=["GET", "POST"]) def index(): short_url = None if request.method == "POST": name = request.form["name"] age = request.form["age"] skills = request.form["skills"] code = generate_short_code() bio_data_storage[code] = {"name": name, "age": age, "skills": skills} short_url = request.host_url + code return render_template_string(form_html, short_url=short_url) @app.route("/") def show_biodata(code): data = bio_data_storage.get(code) if data: return f"

{data['name']}'s Biodata

Age: {data['age']}
Skills: {data['skills']}

" return "

Link not found

", 404 if __name__ == "__main__": app.run(debug=True)