urls.py entry for django v1.10 mysite.com:8000/index.html
<p>I'm having trouble getting the url entry in my app's urls.py file how I want it.
When a person enters <code>mysite.com:8000/</code>, I want it to use the same view as <code>mysite.com:8000/index.html</code>  I can use <code>url(r'^index.html$', views.index, name='index'),</code> and the view is properly displayed when I type <code>mysite.com:8000/index.html</code> into the chrome address bar, or I can trim the <code>.html</code>off both the urls.py entry and the address bar and it's ok, but I figured with regex, I could get this to display for <code>/</code> or for <code>index*</code></p>

<p>lots of googling hasn't let me to an answer yet...</p>

<p>EDIT:
update based on @moses:</p>

<pre><code>from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from . import views

urlpatterns = [
        url(r'^(index\.?[html]{,4})?$', views.index, name='index'),
#       url(r'^index$', views.index, name='index'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
</code></pre>

<p>now I get: "Exception Value:index() takes exactly 1 argument (2 given)"</p>

<p>You can use the following regex pattern that matches 0 or 1 repetitions of <code>'index.html'</code> in the url i.e. either <code>^$</code> or <code>r'^index.html$'</code>:</p>

<pre><code>&gt;&gt;&gt; re.match(r'^(?:index\.html)?$', 'index.html')
&lt;_sre.SRE_Match object; span=(0, 10), match='index.html'&gt;
&gt;&gt;&gt; re.match(r'^(?:index\.html)?$', '')
&lt;_sre.SRE_Match object; span=(0, 0), match=''&gt;
&gt;&gt;&gt; re.match(r'^(?:index\.html)?$', 'login')
&gt;&gt;&gt;
</code></pre>

<p>And your Django url pattern becomes:</p>

<pre><code>url(r'^(?:index.html)?$', views.index, name='index')
</code></pre>

<p>See demo: <a href="https://regex101.com/r/MVCPDN/2" rel="nofollow">https://regex101.com/r/MVCPDN/2</a></p>

python html django