backup
This commit is contained in:
1 parent
d44dc783ee
commit
00c2429cd5
3 files changed
+132
-32
No files matched your search
+17
-2
@@ -1,15 +1,30 @@
|
|||||||
from flask import Flask, render_template, url_for, request, redirect
|
from flask import Flask, render_template, url_for, request, redirect
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
Logs = []
|
||||||
|
Logs.append("Hello World 1");
|
||||||
|
Logs.append("Hello World 2");
|
||||||
|
Logs.append("Hello World 3");
|
||||||
|
Logs.append("Hello World 4");
|
||||||
|
|
||||||
@app.route('/', methods=['POST', 'GET'])
|
@app.route('/', methods=['POST', 'GET'])
|
||||||
def index():
|
def index():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
return 'There was an issue adding your task'
|
if request.form.get('Clear') == 'Clear':
|
||||||
|
Logs.clear();
|
||||||
|
return render_template("index.html",Logs = Logs)
|
||||||
|
elif request.form.get('Randomize') == 'Randomize':
|
||||||
|
Logs.append(str(random.random()));
|
||||||
|
return render_template("index.html",Logs = Logs)
|
||||||
else:
|
else:
|
||||||
return render_template('index.html')
|
return render_template('index.html',Logs = Logs)
|
||||||
|
|
||||||
|
@app.route('/dependent')
|
||||||
|
def i():
|
||||||
|
return render_template('dependent.html')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>
|
||||||
|
Cascading Dependent Dropdown Country, State, City Using JavaScript
|
||||||
|
</title>
|
||||||
|
<style>
|
||||||
|
.worldForm {
|
||||||
|
background: #00bcd4;
|
||||||
|
border: 1px solid #e4e4e4;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.lists {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form class="worldForm">
|
||||||
|
<div class="lists">
|
||||||
|
<label>Select Country:</label>
|
||||||
|
<select name="country" id="countyList">
|
||||||
|
<option value="" selected="selected">Select Country</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="lists">
|
||||||
|
<label>Select State:</label>
|
||||||
|
<select name="state" id="stateList">
|
||||||
|
<option value="" selected="selected">Select State</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="lists">
|
||||||
|
<label>Select City:</label>
|
||||||
|
<select name="city" id="cityList">
|
||||||
|
<option value="" selected="selected">Select City</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var worldData = {
|
||||||
|
USA: {
|
||||||
|
California: ["Los Angeles", "San Diego", "Sacramento"],
|
||||||
|
Texas: ["Houston", "Austin"],
|
||||||
|
Florida: ["Miami", "Orlando", "Tampa"],
|
||||||
|
},
|
||||||
|
India: {
|
||||||
|
Maharashtra: ["Mumbai", "Pune", "Nagpur"],
|
||||||
|
TamilNadu: ["Chennai", "Madurai"],
|
||||||
|
Karnataka: ["Bangalore", "Mangalore"],
|
||||||
|
},
|
||||||
|
Canada: {
|
||||||
|
Alberta: ["Calgary", "Edmonton", "Red Deer"],
|
||||||
|
BritishColumbia: ["Vancouver", "Kelowna"],
|
||||||
|
Manitoba: ["Winnipeg", "Brandon"],
|
||||||
|
},
|
||||||
|
Germany: {
|
||||||
|
Bavaria: ["Munich", "Nuremberg"],
|
||||||
|
NorthRhine: ["Cologne", "Düsseldorf"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
window.onload = function () {
|
||||||
|
var countyList = document.getElementById("countyList"),
|
||||||
|
stateList = document.getElementById("stateList"),
|
||||||
|
cityList = document.getElementById("cityList");
|
||||||
|
for (var country in worldData) {
|
||||||
|
countyList.options[countyList.options.length] = new Option(
|
||||||
|
country,
|
||||||
|
country
|
||||||
|
);
|
||||||
|
}
|
||||||
|
countyList.onchange = function () {
|
||||||
|
stateList.length = 1;
|
||||||
|
cityList.length = 1;
|
||||||
|
if (this.selectedIndex < 1) return;
|
||||||
|
for (var state in worldData[this.value]) {
|
||||||
|
stateList.options[stateList.options.length] = new Option(
|
||||||
|
state,
|
||||||
|
state
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
countyList.onchange();
|
||||||
|
stateList.onchange = function () {
|
||||||
|
cityList.length = 1;
|
||||||
|
if (this.selectedIndex < 1) return;
|
||||||
|
var city = worldData[countyList.value][this.value];
|
||||||
|
for (var i = 0; i < city.length; i++) {
|
||||||
|
cityList.options[cityList.options.length] = new Option(
|
||||||
|
city[i],
|
||||||
|
city[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+15
-30
@@ -4,38 +4,23 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<h3 style="text-align: center">Please choose an application below</h3>
|
<h3 style="text-align: center">Please choose an application below</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Flash Firmware</li>
|
<li>FFlash Firmware</li>
|
||||||
<li>Create PCB Panel</li>
|
<li>Create PCB Panel</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- <h1 style="text-align: center">Task Master</h1>
|
<textarea
|
||||||
{% if tasks|length < 1 %}
|
readonly
|
||||||
<h4 style="text-align: center">There are no tasks. Create one below!</h4>
|
id="w3review"
|
||||||
{% else %}
|
name="w3review"
|
||||||
<table>
|
rows="4"
|
||||||
<tr>
|
cols="50"
|
||||||
<th>Task</th>
|
style="resize: none; width: 600px; height: 500px"
|
||||||
<th>Added</th>
|
>
|
||||||
<th>Actions</th>
|
{% for log in Logs %}{{log}}
|
||||||
</tr>
|
{% endfor %}
|
||||||
{% for task in tasks %}
|
</textarea>
|
||||||
<tr>
|
<form method="post" action="/">
|
||||||
<td>{{ task.content }}</td>
|
<input type="submit" value="Clear" name="Clear" />
|
||||||
<td>{{ task.date_created.date() }}</td>
|
<input type="submit" value="Randomize" name="Randomize" />
|
||||||
<td>
|
|
||||||
<a href="/delete/{{task.id}}">Delete</a>
|
|
||||||
<br>
|
|
||||||
<a href="/update/{{task.id}}">Update</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="form">
|
|
||||||
<form action="/" method="POST">
|
|
||||||
<input type="text" name="content" id="content">
|
|
||||||
<input type="submit" value="Add Task">
|
|
||||||
</form>
|
</form>
|
||||||
</div> -->
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in new issue
Block a user