Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Tech Journal

A Flask + SQLAlchemy blog and events platform.

What changed in this pass

Security

  • Real User model with hashed passwords via Flask-Login, replacing the old hardcoded username/password dict
  • Every admin route (/create, /edit, /delete, /create_event, /edit_event, /delete_event, /dashboard) now requires login — previously these were open to anyone
  • CSRF protection on every form (Flask-WTF)
  • Delete actions are now POST requests with a confirmation prompt, not one-click GET links
  • SECRET_KEY and database URL now come from environment variables instead of being hardcoded
  • Fixed a bug where uploaded post images were saved to the wrong folder and would 404
  • Added file-type validation on post image uploads

Frontend

  • All pages now share one layout.html (header, nav, footer, flash messages) instead of each page duplicating or missing markup
  • Login, dashboard, and the create/edit forms are fully styled to match the rest of the site (previously plain unstyled HTML)
  • Fixed two pages that would crash or silently show nothing due to template variable mismatches (view_post.html, upcoming_events.html)
  • Dashboard now has a proper table view with pagination

Housekeeping

  • Removed the committed venv/ folder and __pycache__
  • Added .gitignore so venv/, .env, and *.db don't get committed again
  • Fixed render.yaml (it had an empty build command)

Local setup

python3 -m venv venv
source venv/bin/activate          # venv\Scripts\activate on Windows
pip install -r requirements.txt

cp .env.example .env
# edit .env and set a real SECRET_KEY, e.g.:
python -c "import secrets; print(secrets.token_hex(32))"

flask db upgrade                  # applies migrations, including the new user table
flask create-admin                # prompts for a username + password
flask run

Your existing posts and events in instance/posts.db are untouched — this only adds the user table.

Creating additional admin users

flask create-admin

Run it again with the same username to reset that user's password.

Deploying (Render)

render.yaml now installs dependencies on build and auto-generates a SECRET_KEY. Before your first deploy there:

  1. Push these changes.
  2. After the service is live, run flask create-admin via Render's shell (or a one-off job) to create your login — don't ship a hardcoded admin password.

Worth knowing: the free Render plan's filesystem is ephemeral, so a SQLite database will reset on redeploy. Fine for now while you're finishing this up, but before you consider it truly production-ready, moving to a persistent Postgres database (Render's free Postgres tier works) is the next step — set DATABASE_URL and the app already reads it.

New in this pass: topics, live events, ads, registration

Topic filtering - posts can now be tagged with a topic (AI, Cybersecurity, DevOps, etc.) when created or edited. The "Topics" sidebar (visible on every page) links to /topic/<name>, listing all posts with that tag.

Persistent sidebar on every page - Upcoming Events, an ad slot, and Topics now render in layout.html itself via a Flask context_processor, so they show up on the homepage, post pages, event pages, about/services - everywhere except the login/dashboard/admin forms (kept clean on purpose via {% set show_sidebar = false %} at the top of those templates).

Live events (Ticketmaster) - fetch_live_tech_events() in app.py calls the Ticketmaster Discovery API, filtered by keyword "technology", cached in memory for 30 minutes. It's merged with your manually-added events (get_combined_events()), sorted by date. If the API key is missing or the request fails for any reason, it fails silently and the site just shows your manual events - it will never crash the site. Set TICKETMASTER_API_KEY in .env to turn it on. Note: I could not verify your specific API key from this sandboxed environment (ticketmaster.com isn't reachable from here) - the integration code is correct and tested against graceful-failure paths, but confirm live results once it's deployed somewhere with open internet access.

Ads (Google AdSense) - the _ad_slot.html partial renders a real AdSense unit if GOOGLE_ADSENSE_CLIENT_ID is set, or a subtle placeholder box otherwise. There are two slots: one in the sidebar (ADSENSE_SLOT_SIDEBAR), and a smaller inline one between Trending and Highlights on the homepage / above each post (ADSENSE_SLOT_INLINE). Your publisher ID is filled into .env.example already - you still need to create ad units in your AdSense dashboard to get slot IDs and drop them into ADSENSE_SLOT_SIDEBAR / ADSENSE_SLOT_INLINE. (Your AdSense "Customer ID" wasn't needed for the embed code itself - that's used for account/reporting purposes, not the ad tag.)

Event registration + confirmation email - clicking "Register Now" (on a local event page, or on a live/external event in the sidebar) opens a shared modal (layout.html). Submitting it POSTs to /events/register, saves a Registration row, attempts to send a confirmation email via Gmail SMTP, and shows a "Registration complete" popup regardless of whether the email succeeded - so a misconfigured mail server never blocks someone from registering. To enable real emails, set MAIL_USERNAME and MAIL_PASSWORD (a Gmail App Password, not your normal password) in .env. For external/live events, the modal also opens the real event's ticket page in a new tab.

Suggestions for later (not done in this pass, kept scope to what was asked)

  • Move to Postgres for durable storage
  • Add image resizing/optimization on upload (currently stored at original size)
  • Rate-limit the login route
  • Add a "forgot password" flow if you'll have more than one admin
  • Consider a lightweight background job (e.g. APScheduler) to refresh the Ticketmaster cache instead of on-request

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages