add robots.txt

This commit is contained in:
minish 2023-02-10 18:57:56 -05:00 committed by minish
parent d0a739386f
commit 176cd813b9
2 changed files with 13 additions and 1 deletions

View File

@ -8,3 +8,14 @@ pub async fn index(State(engine): State<Arc<crate::engine::Engine>>) -> String {
format!("minish's image host, currently hosting {} files", count) format!("minish's image host, currently hosting {} files", count)
} }
// robots.txt that tells web crawlers not to list uploads
const ROBOTS_TXT: &'static str = concat!(
"User-Agent: *\n",
"Disallow: /p/*\n",
"Allow: /\n"
);
pub async fn robots_txt() -> &'static str {
ROBOTS_TXT
}

View File

@ -45,7 +45,7 @@ async fn main() {
if upload_key.is_empty() { if upload_key.is_empty() {
// i would prefer this to be a warning but the default log level hides those // i would prefer this to be a warning but the default log level hides those
error!("upload key is empty! no key will be required for uploading new files"); error!("upload key (BRZ_UPLOAD_KEY) is empty! no key will be required for uploading new files");
} }
// create engine // create engine
@ -64,6 +64,7 @@ async fn main() {
.route("/new", post(new::new)) .route("/new", post(new::new))
.route("/p/:name", get(view::view)) .route("/p/:name", get(view::view))
.route("/", get(index::index)) .route("/", get(index::index))
.route("/robots.txt", get(index::robots_txt))
.with_state(Arc::new(engine)); .with_state(Arc::new(engine));
// start web server // start web server