"Is there something new ?"
This commit is contained in:
parent
f46d5520ca
commit
36c7c277b2
@ -155,6 +155,12 @@ main > article > ol {
|
|||||||
text-justify: distribute;
|
text-justify: distribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main > hr {
|
||||||
|
border-color: var(--mid-bg);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
main > article > img {
|
main > article > img {
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
border-color: var(--mid-bg);
|
border-color: var(--mid-bg);
|
||||||
|
@ -1,14 +1,35 @@
|
|||||||
{% extends "index.html" %}
|
{% extends "index.html" %}
|
||||||
{% block title %}Ajax{% endblock %}
|
{% block title %}Ajax{% endblock %}
|
||||||
{% block main %}
|
{% block main %}
|
||||||
<article class='left'>
|
<section class='inline'>
|
||||||
<h3>Get HTML response from AJAX</h3>
|
<article class='left'>
|
||||||
<p>Click the refresh button to get the HTML response.</p>
|
<h3>Get HTML response from AJAX</h3>
|
||||||
<p>The response may randomly be a voluntary error so you should try it more than once.</p>
|
<p>Click the refresh button to get the HTML response.</p>
|
||||||
Refresh: <input type='button' class='refresh' value=' ' onclick='javascript:get_html_from_ajax(document.getElementById("html_container"), "/get_html_from_ajax");'>
|
<p>The response may randomly be a voluntary error so you should try it more than once.</p>
|
||||||
</article>
|
Refresh: <input type='button' class='refresh' value=' '
|
||||||
<article class='right' id='html_container'>
|
onclick='javascript:get_html_from_ajax(document.getElementById("html_container"), "/get_html_from_ajax");'>
|
||||||
</article>
|
</article>
|
||||||
|
<article class='right'>
|
||||||
|
<h3>Upload files with AJAX</h3>
|
||||||
|
<p>Select files to upload</p>
|
||||||
|
<p>The response may randomly be a voluntary error so you should try it more than once.</p>
|
||||||
|
Upload files:
|
||||||
|
<div class='file_upload'>
|
||||||
|
<!--
|
||||||
|
Input file is a tricky hack (see tetawebapp.css and tetawebapp.js)
|
||||||
|
-->
|
||||||
|
<input type='button' id='upload_icon_1' class='upload' title='Upload' value=' '/>
|
||||||
|
<input type='file' id='upload_input_1' multiple
|
||||||
|
title='Upload'
|
||||||
|
onchange='javascript:upload_file_from_ajax(this, "/upload", "TETA_ERR");'
|
||||||
|
onmouseover='javascript:lit(document.getElementById("upload_icon_1"));'
|
||||||
|
onmouseout='javascript:unlit(document.getElementById("upload_icon_1"));'/>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
<hr/>
|
||||||
|
<article class='right' id='html_container'></article>
|
||||||
|
<hr/>
|
||||||
<section class='inline'>
|
<section class='inline'>
|
||||||
<article class='left'>
|
<article class='left'>
|
||||||
<h3>Set value via AJAX</h3>
|
<h3>Set value via AJAX</h3>
|
||||||
@ -25,17 +46,4 @@
|
|||||||
<input type='button' value="Try me" onclick='javascript:get_value_from_ajax(document.getElementById("value_receiver"), "/get_value_from_ajax", "TETA_ERR");'>
|
<input type='button' value="Try me" onclick='javascript:get_value_from_ajax(document.getElementById("value_receiver"), "/get_value_from_ajax", "TETA_ERR");'>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
<article class='left'>
|
|
||||||
<h3>Upload files with AJAX</h3>
|
|
||||||
<p>Select files to upload</p>
|
|
||||||
<p>The response may randomly be a voluntary error so you should try it more than once.</p>
|
|
||||||
Upload files:
|
|
||||||
<div class='file_upload'>
|
|
||||||
<!--
|
|
||||||
Input file is a tricky hack (see tetawebapp.css and tetawebapp.js)
|
|
||||||
-->
|
|
||||||
<input type='button' id='upload_icon_1' class='upload' title='Upload' value=' '/>
|
|
||||||
<input type='file' id='upload_input_1' multiple title='Upload' value='' onchange='javascript:upload_file_from_ajax(this, "/upload", "TETA_ERR");' onmouseover='javascript:lit(document.getElementById("upload_icon_1"));' onmouseout='javascript:unlit(document.getElementById("upload_icon_1"));'/>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="/static/styles/fonts.css" />
|
<link rel="stylesheet" type="text/css" href="/static/styles/fonts.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="/static/styles/tetawebapp.css" />
|
<link rel="stylesheet" type="text/css" href="/static/styles/tetawebapp.css" />
|
||||||
<link rel="icon" type="image/png" href="/static/images/favicon.png" />
|
<link rel="icon" type="image/png" href="/static/images/favicon.png" />
|
||||||
<script type="text/javascript" src="/static/scripts/tetawebapp.js"></script>
|
<script src="/static/scripts/tetawebapp.js"></script>
|
||||||
</head>
|
</head>
|
||||||
{% block bodyheader %}
|
{% block bodyheader %}
|
||||||
<body>
|
<body>
|
||||||
|
@ -33,7 +33,11 @@
|
|||||||
-->
|
-->
|
||||||
<div class='file_upload'>
|
<div class='file_upload'>
|
||||||
<input type='button' id='upload_icon_1' class='upload' title='Upload' value=' '/>
|
<input type='button' id='upload_icon_1' class='upload' title='Upload' value=' '/>
|
||||||
<input type='file' id='upload_input_1' name='files' multiple title='Upload' value='' onchange='javascript:upload_file_from_ajax(this, "/upload", "TETA_ERR");' onmouseover='javascript:lit(document.getElementById("upload_icon_1"));' onmouseout='javascript:unlit(document.getElementById("upload_icon_1"));'/>
|
<input type='file' id='upload_input_1' name='files' multiple
|
||||||
|
title='Upload'
|
||||||
|
onchange='javascript:upload_file_from_ajax(this, "/upload", "TETA_ERR");'
|
||||||
|
onmouseover='javascript:lit(document.getElementById("upload_icon_1"));'
|
||||||
|
onmouseout='javascript:unlit(document.getElementById("upload_icon_1"));'/>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<pre>
|
<pre>
|
||||||
|
@ -253,8 +253,8 @@ def set_value_from_ajax(value):
|
|||||||
@app.route("/upload", methods=['POST'])
|
@app.route("/upload", methods=['POST'])
|
||||||
@check_session
|
@check_session
|
||||||
def upload():
|
def upload():
|
||||||
""" Accept a value from an AJAX request
|
""" Save a file from AJAX request
|
||||||
It may return an error code for testing purpose """
|
Files are saved in UPLOADED_FILES_DEST (see config.local.py) """
|
||||||
err_code = 'TETA_ERR'
|
err_code = 'TETA_ERR'
|
||||||
RND = int(random.random()*10)
|
RND = int(random.random()*10)
|
||||||
if RND % 2:
|
if RND % 2:
|
||||||
@ -267,7 +267,7 @@ def upload():
|
|||||||
print "Uploaded files:"
|
print "Uploaded files:"
|
||||||
for f in uploaded_files:
|
for f in uploaded_files:
|
||||||
print ' [+] %s [%s]' % (f.filename, f.content_type)
|
print ' [+] %s [%s]' % (f.filename, f.content_type)
|
||||||
# Befor saving you should:
|
# Before saving you should:
|
||||||
# - Secure the filename
|
# - Secure the filename
|
||||||
# - Check file size
|
# - Check file size
|
||||||
# - Check content type
|
# - Check content type
|
||||||
|
Loading…
Reference in New Issue
Block a user