Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quotsie
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joschua (λ)
quotsie
Commits
bc1deea3
Unverified
Commit
bc1deea3
authored
4 months ago
by
Joschua Kesper
Browse files
Options
Downloads
Patches
Plain Diff
Added `--local` option for easier testing
parent
3584e3fe
No related branches found
No related tags found
No related merge requests found
Pipeline
#253243
passed
4 months ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.rs
+9
-4
9 additions, 4 deletions
src/main.rs
with
9 additions
and
4 deletions
src/main.rs
+
9
−
4
View file @
bc1deea3
mod
markov
;
use
std
::{
fs
,
path
::
Path
};
use
std
::{
fs
,
path
::
Path
,
net
::
Ipv4Addr
};
use
anyhow
::
Result
;
use
clap
::{
arg
,
Parser
};
...
...
@@ -58,19 +58,24 @@ impl Api {
struct
Args
{
#[arg(short,
long)]
file
:
String
,
#[arg(short,
long)]
local
:
bool
,
}
#[tokio::main(flavor
=
"current_thread"
)]
async
fn
main
()
->
Result
<
()
>
{
let
service
=
OpenApiService
::
new
(
Api
::
from_file
(
Args
::
parse
()
.file
)
?
,
"mew"
,
"1.0"
)
let
args
=
Args
::
parse
();
let
service
=
OpenApiService
::
new
(
Api
::
from_file
(
args
.file
)
?
,
"mew"
,
"1.0"
)
.server
(
"http://czi.wtf"
);
let
app
=
Route
::
new
()
.nest
(
"/"
,
service
.clone
())
.nest
(
"/docs"
,
service
.clone
()
.swagger_ui
());
println!
(
"starting server on http://0.0.0.0:6969"
);
Server
::
new
(
TcpListener
::
bind
(
"0.0.0.0:6969"
))
let
bind_ip
=
if
args
.local
{
Ipv4Addr
::
new
(
127
,
0
,
0
,
1
)
}
else
{
Ipv4Addr
::
new
(
0
,
0
,
0
,
0
)};
println!
(
"starting server on http://{}:6969"
,
bind_ip
);
Server
::
new
(
TcpListener
::
bind
((
bind_ip
,
6969
)))
.run
(
app
)
.await
?
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment