Skip to content

backend #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions server.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'dart:io';

import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart';
import 'package:shelf_router/shelf_router.dart';


void main(List<String> args) async {
// Use any available host or container IP (usually `0.0.0.0`).
final ip = InternetAddress.anyIPv4;
// final ip="localhost";

final int port = int.parse(Platform.environment["Port"]?? '8080');

// Configure routes.
final router = Router()
//..post('/homepage', (Request req){
//return Response.ok("shuruq alharthi");
//})
..get('/lab', (Request req){
return Response.ok("doing the lab");
})

..get('/shuruq', (Request req){
return Response.ok("smart shuruq");
})

..get('/sleepy', (Request req){
return Response.ok("shuruq is sleepy");
});
final server = await serve(router, ip, port);
print('Server listening on port http://${server.address.host}: ${server.port}');
}