Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
IT NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
IT NachrichtenEverything new coming to Meta’s AI agent Muse(24.09.2026 um 03:13 Uhr)
AI & KI NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:30 Uhr)
AI & KI NachrichtenEverything new coming to Meta’s AI agent Muse(24.09.2026 um 03:13 Uhr)
IT Security NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
IT NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:26 Uhr)
IT NachrichtenEverything new coming to Meta’s AI agent Muse(24.09.2026 um 03:13 Uhr)
AI & KI NachrichtenAI spend will jump 49.5% in 2026, says Gartner(24.09.2026 um 03:30 Uhr)
AI & KI NachrichtenEverything new coming to Meta’s AI agent Muse(24.09.2026 um 03:13 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Flask Subdomains

In this tutorial, I’m going to show you how to work with subdomains in your Flask application. But first … What is a subdomain? A subdomain is a simple extension of the main domain; it’s almost like a username, but at the start…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In this tutorial, I’m going to show you how to work with subdomains in your Flask application.



But first …






What is a subdomain?



A subdomain is a simple extension of the main domain; it’s almost like a username, but at the start of this. For example, the most commonly used on the web is www, where the main website of a product is frequently hosted. Another example of a subdomain is music.apples.com, where music. is a subdomain of apple.com






Subdomains in Flask



Flask can work easily with subdomains, and a third-party extension isn’t needed for this. Yay!.



You can do it using Nginx, but Nginx is out of the range of this tutorial.






Preparing the environment



First, we need to create a new Python environment to start working with Flask, and update our hosts local file.




  • Create a new folder: mkdir flask-subdomains

  • Enter the folder and start a Python virtualenv inside of this. python -m venv venv

  • Activate your virtualenv.

  • Make a new file named main.py. Also, the templates folder.

  • Open your hosts file and add the domain as follows.




127.0.0.1 superdomain.com
127.0.0.1 admin.superdomain.com
127.0.0.1 user1.superdomain.com







If you don’t know where the hosts file is located. For Linux, go to etc/hosts, and for Windows, run Notepad as administrator, follow the next path c:\Windows\System32\drivers\etc, here is the hosts file located on Windows, then change the search filter from Text Files to All Files, and now you can open your hosts file and edit it.







A minimal Flask application



Now, in our main.py file, let’s create a Flask instance and add some routes.




from flask import Flask, render_template


app = Flask(__name__)
app.config['SERVER_NAME'] = 'superdomain.com:5000'


@app.route('/')
def index():
context = { 'page_title': 'Home' }
return render_template('site/index.html.jinja', **context)






Now we have our environment and our minimal Flask application ready to work with.






Our first subdomain



In our main.py file, we need to add a new route and set the subdomain parameter in the decorator




@app.route('/', subdomain='admin')
def admin():
context = { 'page_title': 'Admin Page' }
return render_template('admin/index.html', **context)






The subdomain parameter must match the subdomains defined in the hosts file. Let’s run the server.




flask -A main:app --debug run






Open the browser, and run superdomain.com:5000; now, we can access the main page. If we visit admin.superdomain.com:5000, we can see the admin page... Wait, there’s a problem.



Main route in the browser



Admin route doesn't



The admin route is rendering the site template. What’s wrong?






Fixing the problem



In Flask, we need to set one more thing: The subdomain_matching parameter.




from flask import Flask, render_template


app = Flask(__name__, subdomain_matching=True)






Stop the server, and run it again. This time, we were able to access the subdomain index route.



And… Yay!!! Now, our routes are working well.



Admin route working






Working with Blueprints



Flask has the concept of Blueprints, which lets us make our application modular when we need more flexibility and a better structure for larger projects. The Blueprint object can also set a subdomain without passing it in each new route. This is great if you are building a big application.



Let’s modify our current application.



First, let’s create an app folder. The app folder will contain all the new code, and the main.py file will serve as our entrypoint.



Inside the app folder add the __init__.py file and the blueprints folder with the following files: __init__.py, admin.py, site.py, and tenant.py.

It should look like this:




app
|-blueprints
|-admin.py
|-site.py
|-tenant.py
|-__init__.py
|-__init__.py
main.py






Now, we need to define the blueprints for each module, and set the subdomain parameter, as follows…




# blueprints/admin.py
mod = Blueprint('admin', __name__, subdomain='admin')


@mod.route('/')
def index():
return render_template('admin/index.html.jinja')


# blueprints/site.py
mod = Blueprint('site', __name__)


@mod.route('/')
def index:
return render_template('site/index.html.jinja')


# blueprints/tenant.py
mod = Blueprint('tenant', __name__, subdomain='<string:subdomain>')


@mod.route('/')
def index(subdomain: str):
template_name = 'tenant/index.html.jinja'
return render_template(template_name, subdomain=subdomain)






We set the tenant subdomain to be dynamic and passed it to the index decorated function.

Then, we have to register each blueprint in our main.py file




from flask import Flask

from app.blueprints import admin, site, tenant


app = Flask(__name__, subdomain_matching=True)
app.config['SERVER_NAME'] = 'superdomain.com:5000'
app.register_blueprint(admin.mod)
app.register_blueprint(site.mod)
app.register_blueprint(tenant.mod)






If we visit the user1.superdomain.com:5000, we can see the dynamic tenant route working.



Dynamic subdomain working



Dynamic subdomains could be helpful in some cases, for example, vercel, or the postcard.page site, which allows users to host a site using their domain.

Also, the subdomain allows you to retrieve information from the database related to an organization or user, something like this:




@mod.route('/')
def index(subdomain: str):
tenant = tenants.get_by_subdomain_or_404(subdomain)
all_post = posts.get_all_by_tenant(tenant_id=tenant.id)

return render_template('tenant/index.html.jinja', **{
'tenant': tenant,
'posts': all_posts
})









Conclusion



In this simple tutorial, you learned how to work with subdomains in your Flask application. Remember, this is just at the app level; you’ll need to configure the subdomains in your hosting or domain name providers and use something like Nginx alongside Flask.



I hope you enjoy this post, and thanks for reading. See you next time.



#flask

#webdevelopment

#python

CTI Threat Relationship Graph3 Knoten / 2 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
SOC Incident Playbook: Remote Code Execution (RCE) Defense
title: Detect Exploitation - Flask Subdomains
id: 6284a93a-7bf5-4022-908f-ebe049eaf296
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Flask Subdomains" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Flask Subdomains.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Flask Subdomains

Thematisch verwandte Begriffe: Flask, Subdomains · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96676 | A vulnerability was identified in Fast FAC1900R 20190827_2.0.2. The impa…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick