<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def view_page(name=None):
 """Serve a page name. .. note:: this is a bottle view * if the view is called with the POST method, write the new page content to the file, commit the modification and then display the html rendering of the restructured text file * if the view is called with the GET method, directly display the html rendering of the restructured text file Keyword Arguments: :name: (str) -- name of the rest file (without the .rst extension) OPTIONAL if no filename is given, first try to find a "index.rst" file in the directory and serve it. If not found, serve the meta page __index__ Returns: bottle response object """

    if request.method == 'POST':
        if name is None:
            # new file
            if len(request.forms.filename) > 0:
                name = request.forms.filename

        if name is not None:
            filename = "{0}.rst".format(name)
            file_handle = open(filename, 'w')
            file_handle.write(request.forms.content.encode('utf-8'))
            file_handle.close()
            add_file_to_repo(filename)
            commit(filename)

    response.set_header('Cache-control', 'no-cache')
    response.set_header('Pragma', 'no-cache')
    if name is None:
        # we try to find an index file
        index_files = glob.glob("./[Ii][Nn][Dd][Ee][Xx].rst")
        if len(index_files) == 0:
            # not found
            # redirect to __index__
            return view_meta_index()
        else:
            name = index_files[0][2:-4]
    files = glob.glob("{0}.rst".format(name))
    if len(files) > 0:
        file_handle = open(files[0], 'r')
        html_body = publish_parts(file_handle.read(),
                                  writer=AttowikiWriter(),
                                  settings=None,
                                  settings_overrides=None)['html_body']
        history = commit_history("{0}.rst".format(name))
        return template('page',
                        type="view",
                        name=name,
                        extended_name=None,
                        is_repo=check_repo(),
                        history=history,
                        gitref=None,
                        content=html_body)
    else:
        return static_file(name, '')