Compare commits

..

3 Commits

Author SHA1 Message Date
Justine Pelletreau
d64e020abb Moved upload size 2023-07-03 18:44:17 +02:00
Justine Pelletreau
fd9addbbf2 Merge branch 'main' of ssh://docker.sq.lan:3022/Rust/SqPad 2023-07-03 18:43:10 +02:00
Justine Pelletreau
aa1789f6b0 Moved upload limit 2023-07-03 18:43:05 +02:00
6 changed files with 31 additions and 6 deletions

View File

@ -23,6 +23,13 @@
margin: 0 auto; margin: 0 auto;
} }
pre {
word-wrap: break-word;
white-space: pre-wrap;
font-size: 18px;
}
#form-container { #form-container {
max-width: 400px; max-width: 400px;
margin: 0 auto; margin: 0 auto;

0
Files/posts.json Normal file
View File

View File

@ -19,6 +19,22 @@ The link can be used via a browser normally; it can also be used with curl or wg
For now, notes are kept forever until some admin manually removes them. For now, notes are kept forever until some admin manually removes them.
TODO : ## Warnings
* Put the "files" folder somewhere else The size of a post is limited to 1MB. This value can be changed in the source code, see the end of the main function, at the bottom of src/main.rs :
* Write a dockerfile ```rust
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(move || {
App::new()
//Limit is configured here
.app_data(web::FormConfig::default().limit(1024 * 1000))
.service(get_index)
.service(post_index)
.service(show_post)
})
.bind(("0.0.0.0", 8080))?
.run()
.await
}
```

BIN
sqpad

Binary file not shown.

Binary file not shown.

View File

@ -125,12 +125,12 @@ async fn show_post(path: web::Path<(u64, String)>, req: HttpRequest) -> impl Res
let _ = &mut ret_text.push_str(&format!("\n\ let _ = &mut ret_text.push_str(&format!("\n\
<b>This is the link to your post. Don't lose it !\ <b>This is the link to your post. Don't lose it !\
It can also be accessed raw using Curl or Wget.</b><br>\n\ It can also be accessed raw using Curl or Wget.</b><br>\n\
><i>{} @{}</i><br><br>\n", post.name, post.date)); ><i>{} @{}</i><br><br>\n<pre>\n", post.name, post.date));
let _ = match decrypt(post.crypt, &password) { let _ = match decrypt(post.crypt, &password) {
Ok(v) => { Ok(v) => {
let _ = &mut ret_text.push_str(&v); let _ = &mut ret_text.push_str(&v);
let _ = &mut ret_text.push_str("\n"); let _ = &mut ret_text.push_str("\n</pre>\n");
ret_text.push_str("</body>\n</html>"); ret_text.push_str("</body>\n</html>");
break; break;
}, },
@ -158,8 +158,10 @@ async fn get_index() -> impl Responder {
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
HttpServer::new(move || {
App::new() App::new()
.app_data(web::FormConfig::default().limit(1024 * 1000))
.service(get_index) .service(get_index)
.service(post_index) .service(post_index)
.service(show_post) .service(show_post)