Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wearesimbol/simbol-server
Simple Web and WebSocket server, specially for sites that use Simbol
https://github.com/wearesimbol/simbol-server
Last synced: 1 day ago
JSON representation
Simple Web and WebSocket server, specially for sites that use Simbol
- Host: GitHub
- URL: https://github.com/wearesimbol/simbol-server
- Owner: wearesimbol
- License: mit
- Created: 2018-08-21T05:14:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-18T08:49:48.000Z (over 6 years ago)
- Last Synced: 2024-11-09T18:30:36.668Z (about 2 months ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simbol server
A simple HTTP and WebSocket server built on top of [Iron](https://github.com/iron/iron) and [ws](https://ws-rs.org/). Easily get started with a Simbol app
## Quick start
In the root directory of you web project, create a server directory for the [Rust](https://www.rust-lang.org) server:
```bash
mkdir server
mkdir server/src
cd server
```Create a `Cargo.toml` and add the dependency to it:
```toml
[dependencies]
simbol-server = "1.0.0"
```Create a `main.rs` file in the `server/src` directory with the following content:
```rust
extern crate simbol;use std::thread;
use simbol::server::*;
use simbol::multivp::*;fn main() {
let mut routes: Vec = Vec::new();
routes.push(Route {
mount_path: String::from("/build/"), // Mount path, referring to which part of the URL it takes care of
relative_path: String::from("build"), // The actual relative path to the content from your project's root directory
});
routes.push(Route {
mount_path: String::from("/assets/"),
relative_path: String::from("assets"),
});
let server = SimbolServer::new(String::from("../"), 3000, routes);
let http_handle = thread::spawn(move || {
server.run_server();
});let multivp_server = MultiVP::new(String::from("localhost"), 8091);
let ws_handle = thread::spawn(move || {
multivp_server.run_server();
});http_handle.join().unwrap();
ws_handle.join().unwrap();
}
```This will create and run an HTTP server with the default roots to load:
- `index.html` from `/index.html`
- The different files in `/*`
- Your assets, such as GLTF files, from `/assets/`
- Your built files, such as your JS and CSS, from `/build/`It will also create and run a WebSocket server for the multiVP (social) component of Simbol
Then run it:
`cargo run`
## Contributing
Check out the [Contribution guide](https://github.com/wearesimbol/simbol/blob/master/CONTRIBUTING.md)! If you have any questions, join our [community](http://spectrum.chat/simbol)
## License
This program is free software and is distributed under an [MIT License](https://github.com/wearesimbol/simbol-server/blob/master/LICENSE).