-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_example.py
49 lines (43 loc) · 1.83 KB
/
basic_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
__author__ = 'RD'
import flask
import pandas as pd
from flask import Flask, render_template, request
from searchData import searchData
# from flask_app import app as application
html = """
<! DOCTYPE html>
<html lang = "en">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/dataTables.semanticui.min.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.21/js/dataTables.semanticui.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/semantic.min.js"></script>
<script>
$(document).ready( function () {
$('#my_id').DataTable();
} );
</script>
<head>
<meta charset = "UTF-8">
<title>California's Open Water and Ecological Data Results</title>
</head>
<body>
{{table | safe}}
</body>
</html>
"""
app = Flask(__name__)
@ app.route ('/')
@app.route('/')
def index():
return render_template('about.html')
@app.route('/hello', methods=['POST'])
def hello():
first_name = request.form['first_name']
output = searchData(first_name)
return flask.render_template_string (html, table = output.to_html (header = 'true', classes =['ui celled table','hover'], table_id = 'my_id', render_links=True))
if __name__ == '__main__':
app.run()