Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 437961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:37:50+00:00 2026-05-12T20:37:50+00:00

I am writing a GUI application using Django 1.1.1. This is the views.py: from

  • 0

I am writing a GUI application using Django 1.1.1.

This is the views.py:

from django.http import HttpResponse

def mainpage(request):
    f=open('pages/index.html','r').readlines()
    out=''''''
    for line in file:
        out+=line

    print out
    return HttpResponse(out)

I am trying to load the contents of index.html which is inside a folder pages inside the GUI application folder.

My project’s urls.py is

from django.conf.urls.defaults import *
from gui.views import *

urlpatterns = patterns('',

    (r'^/$', mainpage)   
)

When I run the server I get a 404 error for the root site.
How can I load the index.html file through views?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:37:51+00:00Added an answer on May 12, 2026 at 8:37 pm

    Got it! 😉

    It seems that the mainpage function actually runs on the urls.py (as it is imported from the views.py) file so the path I must provide is gui/pages/index.html. I still had a problem, ‘type object not iterable’, but the following worked:

    def mainpage(request):
        f=open('gui/pages/index.html','r').readlines()
        return HttpResponse(f)
    

    And url pattern was r’^$’ so it worked on http://localhost:8080/ itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a GUI application in Python using wxPython and I want to display
I'm writing a GUI for an application using Swing, and in the interests of
I'm writing a GUI application using Qt 4.7 on Windows 7 Ultimate 32 bit.
I am writing a GUI application to run on a touchscreen device using VB.NET
I am writing an application in Python using Tkinter to manage my GUI. There
I'm writing a GUI in C#, Visual Studio 2008, using the Designer and WinForms.
I'm currently writing a small python app that embeds cherrypy and django using py2app.
I'm writing a GUI application that regularly retrieves data through a web connection. Since
I am writing a desktop application using SWT. What is the simplest way to
I'm writing a Windows CE application in C++ directly applying the WINAPI. In this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.