Archer is a web framework, which contains a web server. It's made absolutely for learning and practice. I make it by refrencing WSGI and flask, but archer is simpler and do less work.
public class App {
@Archer.router(path="/")
public static Object index(){
return "Hello, World!";
}
public static void main(String[] args) {
var archer = new Archer(App.class);
archer.run(8888);
}
}
then you can click http://127.0.0.1:8888/.
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);
}
}
you can click here to look what happens.