Skip to content

a little web framework, which contains a web server

License

Notifications You must be signed in to change notification settings

lambdafate/Archer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archer

MIT LICENSE

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.

a simple example

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/.

another simple example

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.