# SimpleHTTPRequestHandler x files python processing

**URL:** <https://discuss.python.org/t/simplehttprequesthandler-x-files-python-processing/8456>\
**Category:** Python Help\
**Created:** [April 28, 2021, 7:18pm UTC](https://discuss.python.org/t/simplehttprequesthandler-x-files-python-processing/8456 "2021-04-28T19:18:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![webstrucs](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/webstrucs/32/9290_2.png) [@webstrucs](https://discuss.python.org/u/webstrucs)\
**Post date:** [April 28, 2021, 7:18pm UTC](https://discuss.python.org/t/simplehttprequesthandler-x-files-python-processing/8456/1 "2021-04-28T19:18:44Z")

</div>

I am using the class (SimpleHTTPRequestHandler) to read directories and files (.html) that work perfectly well and are redenried naturally by the browser.

The problem is that I need to make files with extensions (.py) processed and sending the output in (html) so that the browser can render the received html.

I try to do this using the class (SimpleHTTPRequestHandler) and passing the path of the python file (index.py) and the result I get in the browser and the pure python code? Below is the server code and the class that returns the html:

Excerpt from the class : SimpleHTTPRequestHandler

```auto
...
class ROOTDirectory(SimpleHTTPRequestHandler):
    pass

    def do_HEAD(self):
        pass

    def do_GET(self):

        self.path = "index.py"
        # Trigger the do_GET method of the SimpleHTTPRequestHandler class
        SimpleHTTPRequestHandler.do_GET(self)
...

```

Class : index.py output browser :

```auto
#! /usr/local/bin/python3.9

# Class name : Index -> Structure html page :
class Index:

    # Class method : Constructor -> Object Build :
    def __init__ (self):
        pass

    # Class method : build -> : Render code html :
    def view(self):

        # Variable : v_html5 -> Code Html
        v_html5 = """
        <!DOCTYPE html>
        <html lang="pt-BR">
        <head>
            <meta charset="UTF-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title>Webstrucs Action</title>
        </head>
        <body>
            <h1>Action</h1>
            <p>
            Python Web Server For Asynchronous Requests<br>
            Active: active (running)<br>
            File: index.py
            </p>
        </body>
        </html>
        """
        return v_html5

o_html = Index()
o_html.view()

```
