[Python] A quick web application with Bottle!

Introduction

Thinking "I want to make a web application ...", is there a good framework for Python that I'm currently studying? When I looked it up ...

I found something called Bottle, so make a note of it up to Hello Word.

Operating environment

To Hello World

yum update Well, it's basic, so let's do it.

# sudo yum update
Loaded plugins: priorities, update-motd, upgrade-helper
No packages marked for update 

Yeah, the new server is nice.

bottle installation

After investigating various things, I placed the Bottle body with wget ... But I believe in the official documentation! !! 1.png

# pip install bottle
You are using pip version 6.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting bottle
100% |******************************| 73kB 4.0MB/s 
Installing collected packages: bottle
  Running setup.py install for bottle
Successfully installed bottle-0.12.13

Alright, especially Ppoi!

App placement

Use the one in the middle of the Bottle page. Example: “Hello World” in a bottle

Let's make it with an appropriate name.

main_app.py


from bottle import route, run, template

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='localhost', port=8080)

Grant execution authority

Don't forget!

# chmod +x ./main_app.py 

Run

Let's move it!

# python main_app.py 
Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.

Oh! I started listening. Well, try duplicating the terminal and curl it.

$ curl http://localhost:8080/hello/jump
<b>Hello jump</b>!

Hello! !!

The access log is returned to the terminal that was run.

127.0.0.1 - - [29/Jun/2017 09:48:38] "GET /hello/jump HTTP/1.1" 200 18

in conclusion

I even tried Hello Word from Bottle. You should read the official document, right? I think you can hear the voice saying ... I hope it helps someone.

Digression

For the time being, it was Qiita's first post, so I wrote it after practicing, ** Qiita is wonderful! !! **: relaxed: I want to continue in the future!

Recommended Posts

[Python] A quick web application with Bottle!
Run a Python web application with Docker
Web application with Python + Flask ② ③
Web application with Python + Flask ④
Launch a Python web application with Nginx + Gunicorn with Docker
Build a web application with Django
Web application with Python3.3.1 + Bottle (1) --Change template engine to jinja2
Daemonize a Python web app with Supervisor
Let's make a web framework with Python! (1)
Let's make a web framework with Python! (2)
I made a WEB application with Django
If you know Python, you can make a web application with Django
I tried to make a todo application using bottle with python
Web application using Bottle (1)
I made a GUI application with Python + PyQt5
Start a simple Python web server with Docker
Steps to develop a web application in Python
Launch a web server with Python and Flask
Explosive speed with Python (Bottle)! Web API development
Create a Python console application easily with Click
Extract data from a web page with Python
Get a quick Python development environment with Poetry
Hit a method of a class instance with the Python Bottle Web API
[GCP] Procedure for creating a web application with Cloud Functions (Python + Flask)
[Streamlit] I hate JavaScript, so I make a web application only with Python
Until you publish (deploy) a web application made with bottle on Heroku
Implement a simple application with Python full scratch without using a web framework.
Web scraping with python + JupyterLab
BASIC authentication with Python bottle
(Python) Try to develop a web application using Django
Web application development with Flask
[ES Lab] I tried to develop a WEB application with Python and Flask ②
Parse and visualize JSON (Web application ⑤ with Python + Flask)
Quick web scraping with Python (while supporting JavaScript loading)
Web application creation with Django
Web API with Python + Falcon
Web application made with Python3.4 + Django (Part.1 Environment construction)
Build a machine learning application development environment with Python
Make a fortune with Python
A memo about building a Django (Python) application with Docker
Web scraping beginner with python
Create a directory with python
Streamline web search with python
Create a web application that recognizes numbers with a neural network
How to convert an array to a dictionary with Python [Application]
I made a simple book application with python + Flask ~ Introduction ~
[Python] What is a with statement?
Solve ABC163 A ~ C with Python
Operate a receipt printer with python
A python graphing manual with Matplotlib.
Creating a web application using Flask ②
Web scraping with Python ① (Scraping prior knowledge)
Implemented file download with Python + Bottle
Let's make a GUI with python.
Web application development memo in python
Getting Started with Python Web Applications
Solve ABC166 A ~ D with Python
Web scraping with Python First step
I tried web scraping with python.
Deploy a Django application with Docker
Monitor Python web apps with Prometheus