mirror of
https://github.com/actix/examples
synced 2025-06-29 02:10:36 +02:00
Improve the static files example. (#317)
* Improve the static files example. * Replace the broken websocket example with a simple static HTML page. * Show how to serve a second directory which is located inside the main directory but has file listing enabled. * Demonstrate that a hierarchy of static files can be served by placing the JS and CSS files in their respective subfolders. * Document how to use the example in the README. * Improve formatting.
This commit is contained in:
11
static_index/static/root/css/example.css
Normal file
11
static_index/static/root/css/example.css
Normal file
@ -0,0 +1,11 @@
|
||||
body {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
img {
|
||||
transition: .5s ease-in-out;
|
||||
}
|
BIN
static_index/static/root/favicon.ico
Normal file
BIN
static_index/static/root/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
13
static_index/static/root/index.html
Normal file
13
static_index/static/root/index.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/example.css" />
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="/js/example.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Actix-web</h1>
|
||||
<img src="/images/logo.png" alt="Actix logo" />
|
||||
</body>
|
||||
</html>
|
7
static_index/static/root/js/example.js
Normal file
7
static_index/static/root/js/example.js
Normal file
@ -0,0 +1,7 @@
|
||||
jQuery(document).ready(function () {
|
||||
let rotation = 0;
|
||||
jQuery("img").click(function () {
|
||||
rotation += 360;
|
||||
jQuery("img").css({'transform': 'rotate(' + rotation + 'deg)'});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user