Car Simulator
Speed: 0 km/h | Distance: 0 m
Controls: Arrow keys / WASD — Up to accelerate, Down to brake, Left/Right to steer
"""
Single-file Flask web application for a "Polipas" (polyp) treatment clinic.
Features:
- Homepage with clinic info
- Doctor profiles
- Appointment booking form (stored in SQLite)
- Contact form (stored in SQLite)
- Simple admin view to list appointments/messages (protected by a simple password)
- Responsive CSS embedded
How to use: save this file as polipas_clinic_single_file.py, install Flask: pip install flask, then run: python polipas_clinic_single_file.py
Open http://127.0.0.1:5000 in your browser.
This single file contains HTML/CSS templates rendered with render_template_string.
"""
from flask import Flask, request, redirect, url_for, render_template_string, g, flash
import sqlite3
import os
from datetime import datetime
# Configuration
DATABASE = 'polipas_clinic.db'
ADMIN_PASSWORD = 'clinicadmin123' # change this in production
app = Flask(__name__)
app.secret_key = os.urandom(24)
# ---------- Database helpers ----------
def get_db():
db = getattr(g, '_database', None)
if db is None:
db = g._database = sqlite3.connect(DATABASE)
db.row_factory = sqlite3.Row
return db
@app.teardown_appcontext
def close_connection(exception):
db = getattr(g, '_database', None)
if db is not None:
db.close()
def init_db():
db = get_db()
cursor = db.cursor()
# appointments table
cursor.execute('''
CREATE TABLE IF NOT EXISTS appointments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
phone TEXT NOT NULL,
email TEXT,
preferred_date TEXT,
message TEXT,
created_at TEXT NOT NULL
)
''')
# messages table
cursor.execute('''
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT,
subject TEXT,
message TEXT,
created_at TEXT NOT NULL
)
''')
db.commit()
# Initialize DB at startup
with app.app_context():
init_db()
# ---------- Templates (embedded) ----------
BASE_HTML = '''
Polipas Clinic - পলিপাস চিকিৎসা সেবা
{% with messages = get_flashed_messages() %}
{% if messages %}
'''
INDEX_CONTENT = '''
'''
SERVICES_CONTENT = '''
'''
DOCTORS_CONTENT = '''
'''
BOOK_CONTENT = '''
'''
CONTACT_CONTENT = '''
'''
ADMIN_LOGIN_CONTENT = '''
'''
ADMIN_DASH_CONTENT = '''
{% else %}
{% else %}
'''
# ---------- Routes ----------
@app.route('/')
def index():
return render_template_string(BASE_HTML, content=INDEX_CONTENT, year=datetime.now().year)
@app.route('/services')
def services():
return render_template_string(BASE_HTML, content=SERVICES_CONTENT, year=datetime.now().year)
@app.route('/doctors')
def doctors():
return render_template_string(BASE_HTML, content=DOCTORS_CONTENT, year=datetime.now().year)
@app.route('/book', methods=['GET','POST'])
def book():
if request.method == 'POST':
name = request.form.get('name','').strip()
phone = request.form.get('phone','').strip()
email = request.form.get('email','').strip()
preferred_date = request.form.get('preferred_date','').strip()
message = request.form.get('message','').strip()
if not name or not phone:
flash('Please provide at least name and phone.')
return redirect(url_for('book'))
db = get_db()
db.execute('INSERT INTO appointments (name,phone,email,preferred_date,message,created_at) VALUES (?,?,?,?,?,?)',
(name,phone,email,preferred_date,message, datetime.now().isoformat()))
db.commit()
flash('Your booking request has been received. We will contact you soon.')
return redirect(url_for('index'))
return render_template_string(BASE_HTML, content=BOOK_CONTENT, year=datetime.now().year)
@app.route('/contact', methods=['GET','POST'])
def contact():
if request.method == 'POST':
name = request.form.get('name','').strip()
email = request.form.get('email','').strip()
subject = request.form.get('subject','').strip()
message = request.form.get('message','').strip()
if not name or not message:
flash('Please include your name and a message.')
return redirect(url_for('contact'))
db = get_db()
db.execute('INSERT INTO messages (name,email,subject,message,created_at) VALUES (?,?,?,?,?)',
(name,email,subject,message, datetime.now().isoformat()))
db.commit()
flash('Thank you for your message. We will reply soon.')
return redirect(url_for('index'))
return render_template_string(BASE_HTML, content=CONTACT_CONTENT, year=datetime.now().year)
@app.route('/admin', methods=['GET','POST'])
def admin():
if request.method == 'POST':
pw = request.form.get('password','')
if pw != ADMIN_PASSWORD:
flash('Invalid password')
return redirect(url_for('admin'))
db = get_db()
cur = db.execute('SELECT * FROM appointments ORDER BY created_at DESC')
appointments = cur.fetchall()
cur2 = db.execute('SELECT * FROM messages ORDER BY created_at DESC')
messages = cur2.fetchall()
return render_template_string(BASE_HTML, content=ADMIN_DASH_CONTENT, appointments=appointments, messages=messages, year=datetime.now().year)
return render_template_string(BASE_HTML, content=ADMIN_LOGIN_CONTENT, year=datetime.now().year)
# Health check route
@app.route('/health')
def health_check():
return {'status':'ok'}
# ---------- Run ----------
if __name__ == '__main__':
app.run(debug=True)
Polipas Clinic
পলিপাস (Polyp) সংক্রান্ত চেকআপ, পরামর্শ ও চিকিৎসা সেবা। অনলাইন অ্যাপয়েন্টমেন্ট ও টেলিমেডিসিন সুবিধা।
{% for m in messages %}
{% endif %}
{% endwith %}
{{ content|safe }}
{{ m }}
{% endfor %}স্বাগত — Polipas Clinic
আমরা পলিপাস সংক্রান্ত স্বাস্থ্যসেবা প্রদান করি: চেকআপ, এনডোস্কপি রেফারেল, কনসাল্টেশন এবং সার্জিক্যাল ম্যানেজমেন্ট (প্রয়োজনে)। আমাদের অভিজ্ঞ ডাক্তাররা রোগীর উপসর্গ অনুসারে উপযুক্ত চিকিৎসা পরিকল্পনা দেবেন।
Our Approach
- প্রাথমিক অনলাইন পরামর্শ
- চিকিৎসা পরিকল্পনা ও রেফারেল
- টেলিমেডিসিন ও ফলো-আপ
Quick Links
Patient Steps
- অ্যাপয়েন্টমেন্ট বুক করুন
- অনলাইন কনসাল্টেশন / টেলেমেডিসিন
- চাহিদা অনুযায়ী ইন-হসপিটাল রেফারেল
Services
- Initial Consultation (On-site / Telemedicine)
- Diagnostic Tests & Endoscopy Referral
- Non-surgical management & Follow-up
- Surgical referral & pre-op counseling
Our Doctors
Dr. A. Rahman
Gastroenterologist — 12 years experience. Specialized in endoscopic management of polyps.
Dr. S. Akter
Surgeon — Minimally invasive procedures and surgical management.
Dr. M. Karim
General Physician — Initial assessment and referral coordination.
Book an Appointment
Please provide your details — our staff will contact you to confirm.
Contact Us
Send a message and we will reply as soon as possible.
Admin Login
Admin Dashboard
Appointments
{% if appointments %}| # | Name | Phone | Preferred Date | Created |
|---|---|---|---|---|
| {{ a['id'] }} | {{ a['name'] }} | {{ a['phone'] }} | {{ a['preferred_date'] }} | {{ a['created_at'] }} |
| Message: {{ a['message'] }} | ||||
No appointments yet.
{% endif %}Messages
{% if messages %}| # | Name | Subject | Created | |
|---|---|---|---|---|
| {{ m['id'] }} | {{ m['name'] }} | {{ m['email'] }} | {{ m['subject'] }} | {{ m['created_at'] }} |
| {{ m['message'] }} | ||||
No messages yet.
{% endif %}