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