# -*- coding: utf-8 -*-
from bottle import route, run, template
PyList = ['one', 'two', 'three']
@route('/form')
def index():
return template('form.html', list=PyList)
run(host='localhost', port=8080)
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Form</title>
<link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css">
</head>
<body>
<form name="test" method="post" action="">
<div class="btn-group">
<button type="button" data-toggle="dropdown" class="btn btn-default dropdown-toggle">Кнопка <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><input type="submit" name="num" value={{list[0]}}></li>
<li><input type="submit" name="num" value={{list[1]}}></li>
<li><input type="submit" name="num" value={{list[2]}}></li>
</ul>
</div>
</form>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript" src="static/js/social-likes.min.js"></script>
<script type="text/javascript" src="static/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
</body>
</html>
from flask import render_template
from urllib.request import urlopen
from urllib.error import HTTPError
from bs4 import BeautifulSoup
@app.route("/links/")
def parse():
try:
html = urlopen("http://www.site.ru/").read()
except HTTPError as e:
print(e)
soup = BeautifulSoup(html, 'lxml');
links = soup.findAll('a')
return render_template('template.html', links=links)
>>> help('spam')
No Python documentation found for 'spam'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.
help(str) # в python3 можно help('')
>>> class myClass:
... def __init__(self,per):
... self.per=per
>>> cmc = myClass('hello')
>>> cmc1 = myClass('anotherString')
>>> cmc.per
'hello'
>>> cmc1.per
'anotherString'