Bottle + bootstrap + Sina cloud build a cat blog (1), bottlebootstrap

Source: Internet
Author: User

Bottle + bootstrap + Sina cloud build a cat blog (1), bottlebootstrap

Introduction

 

I am not sorry if I haven't updated my blog for a long time. Today I bring my personal projects that I have been practicing. Using the mini-web framework bottle of python and bootstrap to build a simple cat blog on Sina cloud, the website has three sections:

This article is suitable for front-end beginners, but still requires a certain degree of html, css and python basics. I will try to write more details as much as possible. I will post a link first, let's take a look at the actual effect of the website muxicat.applinzi.com ~

 

Ideas

 

The entire process is not complex. It involves three steps:

(1) create a project on Sina cloud and build a repository through git to prepare for subsequent local Code Synchronization

(2) Using bootstrap components and layout systems to develop the structure and presentation of webpages

(3) Use the bottle framework to contact dynamic URLs and pages. This part involves many aspects of the bottle framework, such as webpage templates, static file return, and 404 error handling, I believe this part will give you a preliminary understanding of how to use bottle to build a website.

 

Create an application and synchronize code 

 

Today, I will quickly introduce some operations related to sae and git. There are many ways to build my own website. I can buy my own space and domain name to build a website. If I just want to make a static display website, you can also use jekyll + github and I use sae to save some environment deployment troubles and enjoy other convenient services provided by Sina cloud, and the website traffic is low, the usage cost is close to zero. Let's get started.

 

1. register an account. You don't have to go into details. Now it seems that you can log on to the Weibo account directly, which is much more convenient. Some yundou will be given at first, and you will receive another wave after you take a photo with your ID card and register your real name, it can be up to 1000 yundou, and can be used for a long time without using other services such as mysql database.

Create application interface

Ah, the children of the poor choose the cheapest solution combination, python2.7 standard environment, use git for code management, enter the application domain name in the second-level domain name, fill in the Application name below, and click Create application, OK.

 

2. Download git, create a project folder on the computer, connect git to the repository remotely, and upload the initial code.

Download and install git. The next step is to create a local project folder. In the future, the project code and subfolders will be placed in this folder. Go to the project folder, right-click, and have a Git bash here

Open git and initialize

  

git init

 

Create a file in the folder, ending with wsgi, such as index. wsgi, you can write the code of the Web application in it. If you use the bottle framework, the code is like this. Of course, if you are interested, you can also use other complete python web frameworks, such as django and flask. These frameworks are also built into Sina cloud. However, pay attention to the version when using them. For details, see the documentation.

# -*- coding:utf8 -*-from bottle import Bottleimport saemuxicat = Bottle()@muxicat.route('/')def index_hello():    return "hello, my friend"application = sae.create_wsgi_app(muxicat)

The code first introduces the bottle framework and creates a Bottle object muxicat. The name is your own, but you can keep it consistent later. The following function index_hello returns the string "hello, my friend", which is the information we want to display on the webpage. How can we make it on the homepage of the website, that is, muxicat.applinzi.com? You only need to use a decorator route () to associate the URL with the function return result. Is it easy to understand? Why does the decorator play this role? To be honest, I am also studying it. route () is the link address, so you can also make the return statement appear in other addresses, such as muxicat.applinzi.com/helloand.

In this way, open the URL muxicat.applinzi.com and you will be able to see the simple page Hello, my friend!

 

3. upload code

So how to upload the local code to the repository? It can be done with a few pieces of code, which is easy and semantic and easy to remember.

Before that, establish a connection. The Code is as follows:

git remote add sae https://git.sinacloud.com/your-app-name

Replace the your-app-name with the domain name of the application you created. For example, if I use muxicat, the remote connection is fine.

In the future, you only need to use the following three commands to solve the code upload problem:

git add .
git commit -m "commit infomation"
git push sae mater:1

In this way, after you change the directory code and files, you can submit the latest code and files to git. You can also view the latest display results when you open the website. You can enter the commit information based on the changes to facilitate future withdrawal or review of changes.

Now, let's introduce it to you today. You can leave a comment on any errors or problems in the article. Thank you for reading this article!

 

 

 

 

  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.