Python Bottle Framework Application with Visual Studio

If you are completely new to python then here is the answer for your obvious question what is python and why to learn!

In this tutorial we learn how to create python web application using Bottle Framework with Visual Studio.

Before we start developing our first python web application using visual studio, here are two quick prerequisites

  1. Visual Studio 2017 or above
  2. Install Python on your local machine

Creating Python Web Application

create python web application

We will create our first python web application using bottle framework in visual studio

create python web application

Bottle: Python Web Framework will be installed and local environment step up will be done.

create python web application

All necessary packages for Python application development will be downloaded and installed in local environment

Finally this is how python application structure will look like

python project structure

Now you can simply run the python web application in your local machine

Things to learn in first Python Web Application
  • Whenever we want to create a new page, we have to create view (just like view in MVC) in view folder, the extension is .tpl, we can also use .html page as view and write python code mixing with html code.

    After creating a new view, register the view in routes .py file, like the way we have registered our new tutorial view , here is the code

    def tutorial():
        """Renders the about page."""
        return dict(
            title='Python Tutorial',
            message='Things to learn in Python',
  • In view we can write python code mixing with html code, (the same way we used to write in Php or razor pages)

  • Python class extension is .py, see the ““ in above solution, after creating any new class we must compile solution to use the functionality

  • Like any other web application, in python also we can create any number of master pages or layout pages, layout page has same extension like view, and we can give any name to master page / layout page

  • To attach a layout page / master page to a view, write the below code at the beginning of the view, replace the ‘layout.tpl’ with your master page name, additional properties are optional, you can change the title value as per need
    % rebase('layout.tpl', title='Tutorial Page', year=year)
    Another way to add master page reference
    {% extends "app/layout.html" %}
  • This is how content placeholder is defined in Bootle framework layout page


So far you learned creating a basic python web application!

Now let’s take a quick look at some of very useful tutorial about python development before we start with some real-time example

Hope you can start playing with bottle framework

Python Bottle Framework in Visual Studio
Learn python programming with free python coding tutorials.
Other Popular Tutorials
Python programming examples | Join Python Course