-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
37 lines (31 loc) · 854 Bytes
/
Copy pathApp.java
File metadata and controls
37 lines (31 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import archer.*;
/**
* App: for testing archer
*/
public class App {
@Archer.router(path="/login", method={"GET", "POST"})
public static Object login(){
if(islogin()){
Response.redirect_to("/");
}
if(Request.method().equals("GET")){
return "login.html";
}
Session.set("login", true);
return Response.redirect_to("/");
}
@Archer.router(path="/", method={"GET"})
public static Object index(){
if(!islogin()){
return Response.redirect_to("/login");
}
return "index.html";
}
public static boolean islogin(){
return Session.get("login") != null && (Boolean)Session.get("login");
}
public static void main(String[] args) {
var archer = new Archer(App.class);
archer.run(8888);
}
}