Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pissirSmartHome
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Alfredo Chissotti
pissirSmartHome
Commits
38a8e080
Commit
38a8e080
authored
2 years ago
by
Elisa Giglio
Browse files
Options
Downloads
Patches
Plain Diff
aggiornamenti webapp
parent
1cf7390a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
43
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
WebServer/src/code/Resources.java
+21
-27
21 additions, 27 deletions
WebServer/src/code/Resources.java
WebServer/src/code/Server.java
+0
-1
0 additions, 1 deletion
WebServer/src/code/Server.java
WebServer/webServer.srl
+1
-0
1 addition, 0 deletions
WebServer/webServer.srl
with
22 additions
and
28 deletions
WebServer/src/code/Resources.java
+
21
−
27
View file @
38a8e080
...
...
@@ -22,35 +22,29 @@ public class Resources implements HttpHandler {
String
requestURI
=
exchange
.
getRequestURI
().
toASCIIString
().
replace
(
"/secured/home/"
,
"/"
);
String
requestMethod
=
exchange
.
getRequestMethod
();
if
(
Helper
.
isSameString
(
requestMethod
,
"GET"
))
{
String
response
=
getLocalPage
(
requestURI
);
if
(
response
.
equals
(
"fail"
)){
//nel caso in cui non ci sia il file (perche non stato scaricato), allora creo un file fittizzio per non far crashare tutto il resto
String
[]
requestedPath
=
requestURI
.
split
(
"/"
);
// get the last element of requestedPath and remove .js
String
[]
requestedPage
=
requestedPath
[
requestedPath
.
length
-
1
].
split
(
"\\."
);
String
className
=
requestedPage
[
0
];
// make requested page with the first letter capitalized
className
=
className
.
substring
(
0
,
1
).
toUpperCase
()
+
className
.
substring
(
1
);
response
=
"class "
+
className
+
"{}\nexport default "
+
className
;
}
List
<
String
>
strlist
=
new
ArrayList
<>();
switch
(
requestURI
.
substring
(
1
,
4
))
{
case
"js/"
:
strlist
.
add
(
"text/javascript"
);
break
;
case
"css"
:
strlist
.
add
(
"text/css"
);
break
;
// case "con" : strlist.add("text/plain"); break;
// case "con" : strlist.add("application/json"); break;
// default : strlist.add("text/plain"); break;
default
:
strlist
.
add
(
"text"
);
break
;
}
exchange
.
getResponseHeaders
().
put
(
"content-type"
,
strlist
);
exchange
.
sendResponseHeaders
(
200
,
response
.
getBytes
().
length
);
OutputStream
os
=
exchange
.
getResponseBody
();
os
.
write
(
response
.
getBytes
());
os
.
close
();
}
else
{
if
(!
Helper
.
isSameString
(
requestMethod
,
"GET"
))
{
Helper
.
methodNotAllowed
(
exchange
);
return
;
}
String
response
=
getLocalPage
(
requestURI
);
if
(
response
==
null
||
Helper
.
isSameString
(
response
,
"fail"
)){
//nel caso in cui non ci sia il file (perche non stato scaricato), allora creo un file fittizzio per non far crashare tutto il resto
String
[]
requestedPath
=
requestURI
.
split
(
"/"
);
// get the last element of requestedPath and remove .js
String
[]
requestedPage
=
requestedPath
[
requestedPath
.
length
-
1
].
split
(
"\\."
);
String
className
=
requestedPage
[
0
];
// make requested page with the first letter capitalized
className
=
className
.
substring
(
0
,
1
).
toUpperCase
()
+
className
.
substring
(
1
);
response
=
"class "
+
className
+
"{}\nexport default "
+
className
;
}
List
<
String
>
strlist
=
new
ArrayList
<>();
switch
(
requestURI
.
substring
(
1
,
4
))
{
case
"js/"
:
strlist
.
add
(
"text/javascript"
);
break
;
case
"css"
:
strlist
.
add
(
"text/css"
);
break
;
default
:
strlist
.
add
(
"text"
);
break
;
}
exchange
.
getResponseHeaders
().
put
(
"content-type"
,
strlist
);
Helper
.
sendResponseOk
(
response
,
exchange
);
}
private
static
String
getLocalPage
(
String
uri
)
{
...
...
This diff is collapsed.
Click to expand it.
WebServer/src/code/Server.java
+
0
−
1
View file @
38a8e080
...
...
@@ -80,7 +80,6 @@ public class Server {
server
.
createContext
(
"/js/authentication/"
,
new
Resources
());
server
.
createContext
(
"/js/templates/"
,
new
Resources
());
server
.
createContext
(
"/css/"
,
new
Resources
());
// server.createContext("/conf/",new Resources());
server
.
createContext
(
"/res/"
,
new
ImageRes
());
server
.
createContext
(
"/secured/home/js/"
,
new
Resources
());
server
.
createContext
(
"/secured/home/css/"
,
new
Resources
());
...
...
This diff is collapsed.
Click to expand it.
WebServer/webServer.srl
0 → 100644
+
1
−
0
View file @
38a8e080
3A138A02CF04B956146CEDBAA263F0DCA29654FA
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
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