mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
add README example/multipart
This commit is contained in:
parent
d7d9e8c0e9
commit
a1a77600c6
@ -10,5 +10,5 @@ path = "src/main.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
env_logger = "*"
|
env_logger = "*"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
actix = "^0.3.4"
|
actix = "^0.3.5"
|
||||||
actix-web = { git = "https://github.com/actix/actix-web.git" }
|
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, Stream};
|
||||||
use futures::future::{result, Either};
|
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>>
|
fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>>
|
||||||
{
|
{
|
||||||
@ -46,13 +48,16 @@ fn main() {
|
|||||||
let _ = env_logger::init();
|
let _ = env_logger::init();
|
||||||
let sys = actix::System::new("multipart-example");
|
let sys = actix::System::new("multipart-example");
|
||||||
|
|
||||||
HttpServer::new(
|
let addr = HttpServer::new(
|
||||||
|| Application::new()
|
|| Application::new()
|
||||||
.middleware(middleware::Logger::default()) // <- logger
|
.middleware(middleware::Logger::default()) // <- logger
|
||||||
.resource("/multipart", |r| r.method(Method::POST).a(index)))
|
.resource("/multipart", |r| r.method(Method::POST).a(index)))
|
||||||
.bind("127.0.0.1:8080").unwrap()
|
.bind("127.0.0.1:8080").unwrap()
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
|
let signals = Arbiter::system_registry().get::<ProcessSignals>();
|
||||||
|
signals.send(Subscribe(addr.subscriber()));
|
||||||
|
|
||||||
println!("Starting http server: 127.0.0.1:8080");
|
println!("Starting http server: 127.0.0.1:8080");
|
||||||
let _ = sys.run();
|
let _ = sys.run();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user