I used Pydroid 3 --IDE for Python 3, but I burned my hand and stopped using it!
The linux screen will appear.
sudo apt update
sudo apt upgrade -y
sudo apt install -y vim
vim test.c
#include <stdio.h>
int main(){
printf("hello world\n");
}
hirata@localhost:~$ cc test.c
hirata@localhost:~$ ./a.out
hello world
hirata@localhost:~$
sudo apt update
sudo apt install python3
sudo apt install python3-pip
hirata@localhost:~$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
sudo pip3 install bottle
web.py
from bottle import route, run
@route('/')
def root():
str=""
for i in range(10):
str=str+"<h1>Hello %d</h1>"%i
return str
@route('/hello')
def hello():
return "<h1>Hello World!</h1>"
run(host='192.168.1.16', port=8080, debug=True)
.
|-- app.py
|-- routes.py
|-- static
| |-- content
| | |-- bootstrap-grid.css
| | |-- bootstrap-grid.css.map
| | |-- bootstrap-grid.min.css
| | |-- bootstrap-grid.min.css.map
| | |-- bootstrap-reboot.css
| | |-- bootstrap-reboot.css.map
| | |-- bootstrap-reboot.min.css
| | |-- bootstrap-reboot.min.css.map
| | |-- bootstrap.css
| | |-- bootstrap.css.map
| | |-- bootstrap.min.css
| | |-- bootstrap.min.css.map
| | |-- jumbotron.css
| | `-- site.css
| |-- fonts
| | |-- glyphicons-halflings-regular.eot
| | |-- glyphicons-halflings-regular.svg
| | |-- glyphicons-halflings-regular.ttf
| | `-- glyphicons-halflings-regular.woff
| `-- scripts
| |-- _references.js
| |-- bootstrap.bundle.js
| |-- bootstrap.bundle.js.map
| |-- bootstrap.bundle.min.js
| |-- bootstrap.bundle.min.js.map
| |-- bootstrap.js
| |-- bootstrap.js.map
| |-- bootstrap.min.js
| |-- bootstrap.min.js.map
| |-- jquery-1.10.2.intellisense.js
| |-- jquery-1.10.2.js
| |-- jquery-1.10.2.min.js
| |-- jquery-1.10.2.min.map
| |-- jquery.validate-vsdoc.js
| |-- jquery.validate.js
| |-- jquery.validate.min.js
| |-- jquery.validate.unobtrusive.js
| |-- jquery.validate.unobtrusive.min.js
| |-- modernizr-2.6.2.js
| |-- respond.js
| `-- respond.min.js
`-- views
|-- about.tpl
|-- contact.tpl
|-- index.tpl
`-- layout.tpl
app.py
"""
This script runs the application using a development server.
"""
import bottle
import os
import sys
# routes contains the HTTP handlers for our server and must be imported.
import routes
if '--debug' in sys.argv[1:] or 'SERVER_DEBUG' in os.environ:
# Debug mode will enable more verbose output in the console window.
# It must be set at the beginning of the script.
bottle.debug(True)
def wsgi_app():
"""Returns the application to make available through wfastcgi. This is used
when the site is published to Microsoft Azure."""
return bottle.default_app()
if __name__ == '__main__':
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static').replace('\\', '/')
HOST = os.environ.get('SERVER_HOST', 'localhost')
try:
PORT = int(os.environ.get('SERVER_PORT', '5555'))
except ValueError:
PORT = 5555
@bottle.route('/static/<filepath:path>')
def server_static(filepath):
"""Handler for static files, used with the development server.
When running under a production server such as IIS or Apache,
the server should be configured to serve the static files."""
return bottle.static_file(filepath, root=STATIC_ROOT)
# Starts a local test server.
HOST,PORT="192.168.1.16",8080
bottle.run(server='wsgiref', host=HOST, port=PORT)
routes.py
"""
Routes and views for the bottle application.
"""
from bottle import route, view
from datetime import datetime
@route('/')
@route('/home')
@view('index')
def home():
"""Renders the home page."""
return dict(
year=datetime.now().year
)
@route('/contact')
@view('contact')
def contact():
"""Renders the contact page."""
return dict(
title='Contact',
message='Your contact page.',
year=datetime.now().year
)
@route('/about')
@view('about')
def about():
"""Renders the about page."""
return dict(
title='About',
message='Your application description page.',
year=datetime.now().year
)
Recommended Posts