Search

Sites > Site > Python

MAMP PRO - Sites - Site - Python

  • Enable Python
    Activate this option if you want to use Python for the selected site.

    This option can only be activated if you have selected Apache as the web server for the site and activated the “wsgi_module” module (Settings -> Server -> Apache).

  • App name
    The app name assigns a URL to a specific target directory. For example, if you use the value “site-1-app” here, your Python project (the app index.py file) can be accessed in the browser via the URL “https://site-1:8890/site-1-app” (may differ depending on your site name, SSL and port settings).

    • Open
      To open your site in your default browser, click on the “Open” button to the right of the site name field. This button is only active when the servers are running.

    • Open in The “Open in” button allows you to open the sites’s website in a specific browser. This button is only active when the servers are running.

  • Proces Group
    Enter the name of the desired process group here. You can combine several Python apps in a process group. When you activate the “Enable Python” option, MAMP PRO creates a separate process group for each of your Python apps.

  • App index.py File
    In web applications, the “index.py” file serves as the main file/initialization script that starts the application code and executes certain tasks, such as setting up a database connection or loading configurations.

    • Choose…
      Here you can choose the directory and the file name. By default, this file is located at “DOCUMENT_ROOT/index.py”.

    • Edit…
      Click on this button to open the selected file in the editor of MAMP PRO.

    • Open in
      Click on this button to open the selected file in a program of your choice (e.g. a text editor).

  • Advanced Options

    • Virtual Env Path
      Here you specify the path to a virtual environment to be used for the selected site. A virtual environment is an isolated Python environment that makes it possible to manage project-related dependencies separately from other projects and the global Python interpreter.

      • New…
        Click this button to create a virtual environment and assign it to the site.

        You can define the name (corresponding to the directory name) and specify whether installed third-party packages (site-packages) should be added to the Python installation of MAMP PRO. If these two options are not visible to you, you can show them by clicking on the “Options” button.

        MAMP PRO - Sites - Site - Python - create virtual environment

      • Choose…
        Click on this button to select a virtual environment.

      • Unset
        Click on this button to reset the selection of the “Virtual Env Path”. The virtual environment itself remains unchanged.

  • Directive <Directory> in http.conf
    Here you can directly edit the Python configuration, which is written to the Apache configuration file “http.conf”.

    • Edit…
      Clicking on this button opens the template for the Python configuration for editing. You can use the following placeholders in this template:

      • MAMP_PythonAppName_MAMP ← field “App Name”
      • MAMP_PythonProcessGroup_MAMP ← field “Process Group”
      • MAMP_PythonAppAlias_MAMP ← field “App Name”
      • MAMP_PythonIndexPyPath_MAMP ← field “App index.py File”
      • MAMP_VirtualHost_DocumentRoot_MAMP ← field “Document root”
      • MAMP_VirtualHost_Port_MAMP ← field “Port number”

      MAMP PRO - Sites - Site - Python - Directive Directory in http.conf - Edit

    • View…
      Clicking on this button opens the Python configuration for viewing. The placeholders have been replaced by the real values.

      MAMP PRO - Sites - Site - Python - Directive Directory in http.conf - View

    • Reset…
      Clicking on this button resets the template for the Python configuration.

      MAMP PRO - Sites - Site - Python - Directive Directory in http.conf - Reset