Search code examples
pythondjangoweb-frameworks

Writing webapps in python without Django or any framework


I am working on an app that requires a web front-end. All I care about is a HTTP interface for the iOS, Android Apps to talk to. The backend will be using MongoDB.

Do I need to use a Python framework for that? I see that Django wants to generate DB interfaces for me. From a cursory reading of the Django tutorial its not clear why I have to use all those "applications" it comes with like admin, auth etc. I did not see a way to disable the DB interface in Django.

When I wrote php code earlier and all I needed was the php apache module and I got access to the HTTP headers in the php code from where I handled everything myself. Can I not do something like that with python? Why do people use frameworks?


Solution

  • You can try to use Flask, a lightweight web framework, which can help you to make your simple front-end. An example of simple view can be found on the framework website:

    @app.route('/login', methods=['GET', 'POST'])
    def login():
        if request.method == 'POST':
            do_the_login()
        else:
            show_the_login_form()
    

    With Flask, you have no unnecessary module that have Django (admin, auth...) by default, so you can focus on your database management.


    If you want an answer that respect your question, yes you can make a website in Python without framework. WSGI might help you for this, but it will be more difficult.