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

  • Home
  • SEARCH
  • 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 9288079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:50:05+00:00 2026-06-18T19:50:05+00:00

My Flask application structure looks like application_top/ application/ static/ english_words.txt templates/ main.html urls.py views.py

  • 0

My Flask application structure looks like

application_top/
         application/
                    static/
                          english_words.txt
                    templates/
                             main.html
                     urls.py
                     views.py
         runserver.py

When I run the runserver.py, it starts the server at localhost:5000.
In my views.py, I try to open the file english.txt as

f = open('/static/english.txt')

It gives error IOError: No such file or directory

How can I access this file?

  • 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-06-18T19:50:06+00:00Added an answer on June 18, 2026 at 7:50 pm

    I think the issue is you put / in the path. Remove / because static is at the same level as views.py.

    I suggest making a settings.py the same level as views.py Or many Flask users prefer to use __init__.py but I don’t.

    application_top/
        application/
              static/
                  english_words.txt
              templates/
                  main.html
              urls.py
              views.py
              settings.py
        runserver.py
    

    If this is how you would set up, try this:

    #settings.py
    import os
    # __file__ refers to the file settings.py 
    APP_ROOT = os.path.dirname(os.path.abspath(__file__))   # refers to application_top
    APP_STATIC = os.path.join(APP_ROOT, 'static')
    

    Now in your views, you can simply do:

    import os
    from settings import APP_STATIC
    with open(os.path.join(APP_STATIC, 'english_words.txt')) as f:
        f.read()
    

    Adjust the path and level based on your requirement.

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

Sidebar

Related Questions

My project structure looks like flask-appengine-template/ docs/ licenses/ src/ application/ static/ templates/ models.py settings.py
By default Flask uses template files stored in the "templates" directory: /flaskapp /application.py /templates
I am working on a web application using Flask. One of the views is
I am building a flask application, and I want it to serve some static
Say I have a Flask application, served by uWSGI using multiple processes, like: uwsgi
I'm trying to push a Flask application into Heroku. But if i start the
I am creating a fairly large application using Flask and Jinja. Flask recommends separating
With Python web application frameworks such as Flask, webapp2 and Pyramid, how can each
I am new to Flask and am implementing a tiny application. I successfully got
I have a web application which is deployed by the means of Flask. I'm

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.