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 8093257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:27:56+00:00 2026-06-05T20:27:56+00:00

With Python web application frameworks such as Flask, webapp2 and Pyramid, how can each

  • 0

With Python web application frameworks such as Flask, webapp2 and Pyramid, how can each route-handling-function can have its own py file? I don’t want all these functions piled up together in a single file structure. What do I do to make this work in Flask, webapp2 and Pyramid?

Thank you.

  • 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-05T20:27:57+00:00Added an answer on June 5, 2026 at 8:27 pm

    In flask and pyramid (don’t know about webapp2, but probably the same), route-handling-function (let’s call them views) are nothing but function, that are register to an app registry.


    In flask, you can put your view anywhere, as long as you register it :

    app.py :

    from flask import Flask
    app = Flask(__name__)
    

    view.py :

    from app import app
    @app.route("/")
    def hello():
        return "Hello World!"
    

    main.py :

    from app import app
    if __name__ == "__main__":
        app.run()
    

    Same thing for pyramid. I won’t go into the details. The registering process is different, but the idea is the same. But it anywhere, as long as you register it. There are two way to register views :

    • using add_view : the first argument is the dotted path to the function. Put it anywhere, and put the right path here.
    • Using scan : the first argument is a package that is scanned to find the views. Just make sure all your views are in the package and its subpackages, and everything will work.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the 'luck' of develop and enhance a legacy python web application for
I'm developing a web application on App Engine Python. I have a form with
I have a web application build in Django + Python that interact with web
I have a Python application in the bottle web-server that accesses a C shared-object
There are a lot of web application frameworks out there, based in Java/Ruby/Python/PHP amongst
I have a small Python web application using the Cherrypy framework. I am by
I realise that web application frameworks are well documented, yet having tried 2 Python
For a new (Python) web application with the Pyramid web framework, I'd like to
I have a small web.py Python application that I would like to serve under
I have a web application im currently working on in python. I'm using Django

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.