Python Apache Web Server

Posted on  by admin

In my earlier post we have gone thru step by step instructions to install Apache web server from scratch and host https enabled website into it. In this blog we will go thru the step by step instructions to host Python Flask APIs in Apache Web server. This is a requirement when you want to integrate front end Application(Angular SPA) with Azure AD because Angular SPA should call API hosted in Https Endpoint to work with Azure AD. In the production environment you can not use Flask to host your API and you definitely need a production web server like Apache or Gunicorn. Flask is good for development purpose but when you move to production you need to host it in Web server. Here is the example Architecture where it can be helpful.

  • Create a Python Web Server. A webserver in Python can be setup in two ways. Python supports a webserver out of the box. You can start a web server with a one liner. But you can also create a custom web server which has unique functionality. In this article you’ll learn how to do that. The web server in this example can be accessed on your.
  • The final step is to tie the knot between your python website and Apache web server. This is done by executing the below command in terminal. This adds a virtual path to Apache and the Python application would be served as a WSGI application by Apache web server. Sudo /usr/sbin/a2ensite sysinfo.conf.
  • The Apache HTTP Server is a widely deployed web server that can be used in combination with a WSGI module, such as modwsgi or a stand-alone WSGI server to run Python web applications. Why is the Apache HTTP Server important? Apache remains the most commonly deployed web server with a reign of 20+ years.
  • (You probably don't want to run one, or you want a wsgi module for you web server.) – gertvdijk Aug 26 '13 at 19:21 I just want to be able to run a simple python script on a web server. I'm just using the standard apache2 that comes with ubuntu and the stock configuration.

There are already python-based web servers, such as CherryPy (which I think is intended to be a web server solution on the same stack level as Apache; it is more python-based though, and Apache has been around a lot longer).

Step 1.Deploy Mod_ssl and apache web server. Please refer to my earlier post.

Step 2: Install Mod_wsgi module.

Please note that mod_wsgi module is required to host Flask API into Apache web server.

Step 3:Perform Module configuration.


Python Apache Web Server Tutorial

Add the below lines in the ssl.cnf ( SSL config file).Please refer to my earlier post to know what is ssl.cnf’s role here.


Python Apache Web Server Interview

Step 3: Test the API call my using https://serverhostname/apiname. It should work perfectly.

Execute python apache web serverPython apache web server interview

Python Apache Web Server

Hope this post was useful.