Untitled
unknown
plain_text
23 days ago
2.0 kB
0
Indexable
from flask import Flask, render_template, request, redirect, url_for from fpdf import FPDF app = Flask(__name__) # Simple route for the homepage @app.route('/') def index(): return render_template('index.html') # Route to handle form submission @app.route('/submit', methods=['POST']) def submit_data(): radiation_level = request.form['radiation_level'] # Simple compliance check: assuming level should be below 100 compliance = "Compliant" if int(radiation_level) < 100 else "Non-Compliant" # Generate a report report = generate_report(radiation_level, compliance) return report # Function to generate a report def generate_report(radiation_level, compliance): pdf = FPDF() pdf.add_page() pdf.set_font('Arial', 'B', 12) pdf.cell(200, 10, txt="AERB Regulatory Report", ln=True, align='C') pdf.cell(200, 10, txt=f"Radiation Level: {radiation_level}", ln=True) pdf.cell(200, 10, txt=f"Compliance Status: {compliance}", ln=True) # Save the PDF file pdf.output('regulatory_report.pdf') return redirect(url_for('download_report')) # Route to download the report @app.route('/download') def download_report(): return "Report has been generated successfully! You can download it <a href='/static/regulatory_report.pdf'>here</a>." if __name__ == '__main__': app.run(debug=True) 5. HTML Form for Input (index.html) html Copy <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>AERB Data Submission</title> </head> <body> <h1>AERB Regulatory Data Submission</h1> <form action="/submit" method="POST"> <label for="radiation_level">Enter Radiation Level:</label> <input type="text" id="radiation_level" name="radiation_level" required> <button type="submit">Submit</button> </form> </body> </html>
Editor is loading...
Leave a Comment