mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 19:41:12 +00:00
add README example/multipart
This commit is contained in:
parent
d7d9e8c0e9
commit
a1a77600c6
3 changed files with 32 additions and 3 deletions
|
@ -10,5 +10,5 @@ path = "src/main.rs"
|
|||
[dependencies]
|
||||
env_logger = "*"
|
||||
futures = "0.1"
|
||||
actix = "^0.3.4"
|
||||
actix-web = { git = "https://github.com/actix/actix-web.git" }
|
||||
actix = "^0.3.5"
|
||||
actix-web = { git = "https://github.com/actix/actix-web", features=["signal"] }
|
||||
|
|
24
examples/multipart/README.md
Normal file
24
examples/multipart/README.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# multipart
|
||||
|
||||
Multipart's `Getting Started` guide for Actix web
|
||||
|
||||
## Usage
|
||||
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd actix-web/examples/multipart
|
||||
cargo run (or ``cargo watch -x run``)
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
||||
### client
|
||||
|
||||
- ``pip install aiohttp``
|
||||
- ``python client.py``
|
||||
- you must see in server console multipart fields
|
||||
|
||||
if ubuntu :
|
||||
|
||||
- ``pip3 install aiohttp``
|
||||
- ``python3 client.py``
|
|
@ -9,6 +9,8 @@ use actix_web::*;
|
|||
use futures::{Future, Stream};
|
||||
use futures::future::{result, Either};
|
||||
|
||||
use actix::Arbiter;
|
||||
use actix::actors::signal::{ProcessSignals, Subscribe};
|
||||
|
||||
fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>>
|
||||
{
|
||||
|
@ -46,13 +48,16 @@ fn main() {
|
|||
let _ = env_logger::init();
|
||||
let sys = actix::System::new("multipart-example");
|
||||
|
||||
HttpServer::new(
|
||||
let addr = HttpServer::new(
|
||||
|| Application::new()
|
||||
.middleware(middleware::Logger::default()) // <- logger
|
||||
.resource("/multipart", |r| r.method(Method::POST).a(index)))
|
||||
.bind("127.0.0.1:8080").unwrap()
|
||||
.start();
|
||||
|
||||
let signals = Arbiter::system_registry().get::<ProcessSignals>();
|
||||
signals.send(Subscribe(addr.subscriber()));
|
||||
|
||||
println!("Starting http server: 127.0.0.1:8080");
|
||||
let _ = sys.run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue