Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dssp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
dssp
Commits
9f3a5528
Unverified
Commit
9f3a5528
authored
May 30, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working web server
parent
6efb4d31
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
19 deletions
+85
-19
CMakeLists.txt
+2
-1
docroot/index.html
+21
-4
src/dssp-io.hpp
+3
-0
src/dssp-server.cpp
+59
-14
No files found.
CMakeLists.txt
View file @
9f3a5528
...
@@ -109,6 +109,7 @@ if(NOT PDB_REDO_META)
...
@@ -109,6 +109,7 @@ if(NOT PDB_REDO_META)
if
(
BUILD_WEBSERVER
)
if
(
BUILD_WEBSERVER
)
find_package
(
zeep REQUIRED
)
find_package
(
zeep REQUIRED
)
find_package
(
gxrio REQUIRED
)
endif
()
endif
()
endif
()
endif
()
...
@@ -145,7 +146,7 @@ if(BUILD_WEBSERVER)
...
@@ -145,7 +146,7 @@ if(BUILD_WEBSERVER)
${
PROJECT_SOURCE_DIR
}
/src/dssp-io.cpp
${
PROJECT_SOURCE_DIR
}
/src/dssp-io.cpp
${
PROJECT_SOURCE_DIR
}
/src/dssp-server.cpp
)
${
PROJECT_SOURCE_DIR
}
/src/dssp-server.cpp
)
target_link_libraries
(
dsspd PRIVATE dssp cifpp::cifpp libmcfp::libmcfp dssp::dssp zeep::zeep
)
target_link_libraries
(
dsspd PRIVATE dssp cifpp::cifpp libmcfp::libmcfp dssp::dssp zeep::zeep
gxrio::gxrio
)
# yarn rules for javascripts
# yarn rules for javascripts
set
(
webpack_input
set
(
webpack_input
...
...
docroot/index.html
View file @
9f3a5528
<!DOCTYPE html SYSTEM "about:legacy-compat" [
<!DOCTYPE html SYSTEM "about:legacy-compat" [ <!ENTITY nbsp " ">
<!ENTITY nbsp " ">
]>
]>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:z2=
"http://www.hekkelman.com/libzeep/m2"
lang=
"nl"
>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:z2=
"http://www.hekkelman.com/libzeep/m2"
lang=
"nl"
>
...
@@ -26,7 +25,24 @@
...
@@ -26,7 +25,24 @@
<article>
<article>
<h2>
Submit your structure
</h2>
<h2>
Submit your structure
</h2>
<form
z2:fragment=
"submit-form"
name=
"job-form"
method=
"post"
enctype=
"multipart/form-data"
z2:action=
"@{/do}"
>
<div
class=
"input-group mb-3"
>
<label
class=
"input-group-text"
for=
"input-group-pdb-file"
>
Coordinates
</label>
<input
type=
"file"
class=
"form-control"
id=
"input-group-pdb-file"
name=
"data"
required=
"required"
/>
</div>
<div
class=
"input-group mb-3"
>
<label
class=
"input-group-text"
for=
"format-select"
>
Format
</label>
<select
class=
"form-select"
id=
"format-select"
name=
"format"
>
<option
value=
"mmcif"
>
Annotated mmCIF
</option>
<option
value=
"dssp"
>
Historic DSSP format, may fail on larger structures
</option>
</select>
</div>
<button
type=
"submit"
class=
"btn btn-sm btn-primary mt-3"
>
Submit
</button>
</form>
</article>
</article>
...
@@ -35,4 +51,4 @@
...
@@ -35,4 +51,4 @@
<footer
z2:replace=
"~{footer::content}"
></footer>
<footer
z2:replace=
"~{footer::content}"
></footer>
</body>
</body>
</html>
</html>
\ No newline at end of file
src/dssp-io.hpp
View file @
9f3a5528
...
@@ -31,3 +31,6 @@
...
@@ -31,3 +31,6 @@
void
writeDSSP
(
const
dssp
&
dssp
,
std
::
ostream
&
os
);
void
writeDSSP
(
const
dssp
&
dssp
,
std
::
ostream
&
os
);
void
annotateDSSP
(
cif
::
datablock
&
db
,
const
dssp
&
dssp
,
bool
writeOther
,
bool
writeExperimental
,
std
::
ostream
&
os
);
void
annotateDSSP
(
cif
::
datablock
&
db
,
const
dssp
&
dssp
,
bool
writeOther
,
bool
writeExperimental
,
std
::
ostream
&
os
);
void
writeDSSP
(
std
::
istream
&
is
,
std
::
ostream
&
os
);
void
annotateDSSP
(
cif
::
datablock
&
db
,
const
dssp
&
dssp
,
bool
writeOther
,
bool
writeExperimental
,
std
::
ostream
&
os
);
src/dssp-server.cpp
View file @
9f3a5528
...
@@ -28,15 +28,18 @@
...
@@ -28,15 +28,18 @@
#include "revision.hpp"
#include "revision.hpp"
#include <cif++.hpp>
#include <gxrio.hpp>
#include <mcfp.hpp>
#include <mcfp.hpp>
#include <zeep/http/daemon.hpp>
#include <zeep/http/html-controller.hpp>
#include <zeep/http/html-controller.hpp>
#include <zeep/http/rest-controller.hpp>
#include <zeep/http/rest-controller.hpp>
#include <zeep/
http/daemon
.hpp>
#include <zeep/
streambuf
.hpp>
// --------------------------------------------------------------------
// --------------------------------------------------------------------
class
dssp_html_controller
:
public
zeep
::
http
::
html_controller
class
dssp_html_controller
:
public
zeep
::
http
::
html_controller
{
{
public
:
public
:
...
@@ -48,7 +51,7 @@ class dssp_html_controller : public zeep::http::html_controller
...
@@ -48,7 +51,7 @@ class dssp_html_controller : public zeep::http::html_controller
mount
(
""
,
&
dssp_html_controller
::
index
);
mount
(
""
,
&
dssp_html_controller
::
index
);
}
}
void
index
(
const
zeep
::
http
::
request
&
request
,
const
zeep
::
http
::
scope
&
scope
,
zeep
::
http
::
reply
&
reply
)
void
index
(
const
zeep
::
http
::
request
&
request
,
const
zeep
::
http
::
scope
&
scope
,
zeep
::
http
::
reply
&
reply
)
{
{
get_template_processor
().
create_reply_from_template
(
"index"
,
scope
,
reply
);
get_template_processor
().
create_reply_from_template
(
"index"
,
scope
,
reply
);
}
}
...
@@ -59,13 +62,55 @@ class dssp_html_controller : public zeep::http::html_controller
...
@@ -59,13 +62,55 @@ class dssp_html_controller : public zeep::http::html_controller
class
dssp_rest_controller
:
public
zeep
::
http
::
rest_controller
class
dssp_rest_controller
:
public
zeep
::
http
::
rest_controller
{
{
public
:
public
:
dssp_rest_controller
()
dssp_rest_controller
(
const
std
::
string
&
prefix
)
:
zeep
::
http
::
rest_controller
(
""
)
:
zeep
::
http
::
rest_controller
(
prefix
)
{
{
// map_post_request("dssp", &dssp_rest_controller::calculate, "data
");
map_post_request
(
"do"
,
&
dssp_rest_controller
::
work
,
"data"
,
"format
"
);
}
}
zeep
::
http
::
reply
work
(
const
zeep
::
http
::
file_param
&
coordinates
,
std
::
optional
<
std
::
string
>
format
);
};
};
zeep
::
http
::
reply
dssp_rest_controller
::
work
(
const
zeep
::
http
::
file_param
&
coordinates
,
std
::
optional
<
std
::
string
>
format
)
{
zeep
::
char_streambuf
sb
(
coordinates
.
data
,
coordinates
.
length
);
gxrio
::
istream
in
(
&
sb
);
cif
::
file
f
=
cif
::
pdb
::
read
(
in
);
if
(
f
.
empty
())
throw
std
::
runtime_error
(
"Invalid input file, is it empty?"
);
// --------------------------------------------------------------------
short
pp_stretch
=
3
;
//minPPStretch.value_or(3);
std
::
string
fmt
=
format
.
value_or
(
"mmcif"
);
dssp
dssp
(
f
.
front
(),
1
,
pp_stretch
,
true
);
std
::
ostringstream
os
;
if
(
fmt
==
"dssp"
)
writeDSSP
(
dssp
,
os
);
else
annotateDSSP
(
f
.
front
(),
dssp
,
true
,
true
,
os
);
// --------------------------------------------------------------------
std
::
string
name
=
f
.
front
().
name
();
if
(
fmt
==
"dssp"
)
name
+=
".dssp"
;
else
name
+=
".cif"
;
zeep
::
http
::
reply
rep
{
zeep
::
http
::
ok
};
rep
.
set_content
(
os
.
str
(),
"text/plain"
);
rep
.
set_header
(
"content-disposition"
,
"attachement; filename =
\"
"
+
name
+
'"'
);
return
rep
;
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
@@ -90,7 +135,7 @@ int main(int argc, char *argv[])
...
@@ -90,7 +135,7 @@ int main(int argc, char *argv[])
mcfp
::
make_option
<
std
::
string
>
(
"context"
,
""
,
"Root context for web server"
),
mcfp
::
make_option
<
std
::
string
>
(
"context"
,
""
,
"Root context for web server"
),
mcfp
::
make_option
(
"no-daemon,F"
,
"Do not fork into background"
),
mcfp
::
make_option
(
"no-daemon,F"
,
"Do not fork into background"
),
mcfp
::
make_option
<
std
::
string
>
(
"config"
,
"Config file to use"
));
mcfp
::
make_option
<
std
::
string
>
(
"config"
,
"Config file to use"
));
std
::
error_code
ec
;
std
::
error_code
ec
;
...
@@ -124,7 +169,7 @@ int main(int argc, char *argv[])
...
@@ -124,7 +169,7 @@ int main(int argc, char *argv[])
std
::
cout
<<
config
<<
std
::
endl
;
std
::
cout
<<
config
<<
std
::
endl
;
exit
(
0
);
exit
(
0
);
}
}
if
(
config
.
operands
().
empty
())
if
(
config
.
operands
().
empty
())
{
{
std
::
cerr
<<
"Missing command, should be one of start, stop, status or reload"
<<
std
::
endl
;
std
::
cerr
<<
"Missing command, should be one of start, stop, status or reload"
<<
std
::
endl
;
...
@@ -137,8 +182,8 @@ int main(int argc, char *argv[])
...
@@ -137,8 +182,8 @@ int main(int argc, char *argv[])
std
::
string
address
=
config
.
get
<
std
::
string
>
(
"address"
);
std
::
string
address
=
config
.
get
<
std
::
string
>
(
"address"
);
uint16_t
port
=
config
.
get
<
uint16_t
>
(
"port"
);
uint16_t
port
=
config
.
get
<
uint16_t
>
(
"port"
);
z
h
::
daemon
server
([
&
]()
z
eep
::
http
::
daemon
server
([
&
,
context
=
config
.
get
(
"context"
)
]()
{
{
auto
s
=
new
zeep
::
http
::
server
();
auto
s
=
new
zeep
::
http
::
server
();
#ifndef NDEBUG
#ifndef NDEBUG
...
@@ -146,10 +191,10 @@ int main(int argc, char *argv[])
...
@@ -146,10 +191,10 @@ int main(int argc, char *argv[])
#else
#else
s
->
set_template_processor
(
new
zeep
::
http
::
rsrc_based_html_template_processor
());
s
->
set_template_processor
(
new
zeep
::
http
::
rsrc_based_html_template_processor
());
#endif
#endif
s
->
add_controller
(
new
dssp_rest_controller
());
s
->
add_controller
(
new
dssp_rest_controller
(
context
));
s
->
add_controller
(
new
dssp_html_controller
(
con
fig
.
get
(
"context"
)
));
s
->
add_controller
(
new
dssp_html_controller
(
con
text
));
return
s
;
return
s
;
},
},
kProjectName
);
kProjectName
);
std
::
string
command
=
config
.
operands
().
front
();
std
::
string
command
=
config
.
operands
().
front
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment