dartcore 0.0.7 copy "dartcore: ^0.0.7" to clipboard
dartcore: ^0.0.7 copied to clipboard

A simple, powerful Flask alternative for Dart, offering fast and efficient API development with scalability.

Dartcore #

Dartcore is a minimalist, yet powerful HTTP server framework for the Dart programming language. It provides a simple API for routing and handling HTTP requests, making it perfect for lightweight (not very, can be used for complex ones that will never crash) web applications, APIs, or microservices.

Features #

  • Simple and intuitive routing
  • Lightweight and fast
  • Minimal dependencies
  • Easy to use for building RESTful APIs
  • Customizable request handling
  • Looks a bit like Flask :)

Getting Started #

Installation #

Library:

First, ensure you have the Dart SDK installed. Then, add dartcore to your pubspec.yaml file as a dependency.

dependencies:
  dartcore: any

Run dart pub get to install dependencies.

CLI:

You can install it by running the command:

dart pub activate global dartcore

and then try,

dartcore --version

Example Usage #

Follow these simple steps to set up your Dartcore server.

1. Create a New Instance of Dartcore #

import 'package:dartcore/dartcore.dart' as dartcore;
// "" is the config file path
final app = dartcore.App(debug: true); // replace true with false in production mode! this specifies Debugging mode

2. Add Routes #

Use the route method to handle incoming HTTP requests. Specify the HTTP method (e.g., GET, POST, etc.) and the route.

app.route('GET', '/', (req, res) {
  res.send("Hello from Dartcore!", ContentType.text);
});

app.route('GET', '/hello', (req, res) {
  res.json({"from":"Dartcore","message":"Hello World!"});
});

3. Start the Server #

Use the start method to start the server.

app.start(port: 8080);

Optional Parameters:

  • (String) address: The server's IP address (default: 0.0.0.0 --> All IP Addresses).
  • (int) port: The port on which the server listens (default: 8080).

Full Example #

See the full example on pub.dev!

Running the Server #

Run your Dart server with:

dart run

Visit http://127.0.0.1:8080/, http://localhost:8080/, or http://YOUR_PRIVATE_IP:8080/ to see the server in action!


Contributing #

Contributions are welcome! Please feel free to submit issues and pull requests to help improve DartCore.


License #

This project is licensed under the MIT License - see the LICENSE file for details.

Git repo Structure #

REPO | │ Dockerfile == Example Dockerfile │ LICENSE == MIT License │ pubspec.yaml == Packages │ README.md == This │ ├───example == Example project │ │ config.json │ │ main.dart │ │ │ └───templates │ child.html │ hello.html │ └───lib == Library, used in apps

1
likes
160
points
216
downloads

Publisher

unverified uploader

Weekly Downloads

A simple, powerful Flask alternative for Dart, offering fast and efficient API development with scalability.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

aes256, crypto, dio, encrypt, http, http_parser, mime, mysql_client, postgres, toml, uuid, xml, yaml

More

Packages that depend on dartcore