标签: httpserver

可以按需启动的用于 Windows 的简单 HTTP 服务器应用程序?

我需要一个满足以下条件的简单 HTTP 服务器应用程序:

  1. 它必须在 Windows 上运行。
  2. 它必须要求新的任何形式的Windows安装:程序,框架,服务等。
  3. 它可以使用 Java(例如 JAR)或 .NET 运行,因为这些框架已经全局安装在服务器上。
  4. 它必须能够根据需要由 Ant 构建(和/或从命令行)启动停止。
  5. 它必须能够在运行时指定的端口上托管(即不在配置文件中)。
  6. 它必须只能从运行时指定的根目录(即不在配置文件中)托管基本静态内容(JavaScript、CSS、图像、HTML )。
  7. 必须不需要巨大的分发文件夹,例如完整的 Jetty 分发大约 40 MB ......太大了!小于 1 MB 将是首选。
  8. 不是需要支持HTTPS(SSL)。
  9. 需要任何的IDE集成。
  10. 不是需要举办任何“Web应用程序”,例如耳朵,战争,JAR文件等。

有什么建议吗?我还需要一个指南/教程解释来设置它们,特别是如果它们是基于 Java 的,因为我在 Java 方面的背景很少(老实说在 Ant 方面也没有那么多背景)。

谢谢!

apache ant jetty httpserver

6
推荐指数
1
解决办法
3390
查看次数

如何在使用python的HTTPServer时设置DocumentRoot?

我有以下代码作为我的python服务器:

#!/usr/bin/python3
from http.server import HTTPServer, CGIHTTPRequestHandler

port = 8080
host_name = "localhost"
httpd = HTTPServer((host_name, port), CGIHTTPRequestHandler)
print("server started, to quit press <ctrl-c>")
httpd.serve_forever()
Run Code Online (Sandbox Code Playgroud)

如何设置服务器为其提供服务的DocumentRoot.

python httpserver python-3.x

6
推荐指数
1
解决办法
1万
查看次数

如何在Prolog动态提供的HTML页面中包含图像?

如果我将Prolog HTTP服务器绑定到localhost端口9000,我怎样才能让Prolog为我的图像生成正确的路径?例如,如果我的.pl文件和/ .jpg.png文件位于桌面上,如何让服务器生成如下代码:

<img src="C:\Users\Luka\\Desktop\ImageName.ext"/>,"ext"代表扩展名.我已经看了SWI-Prolog和本教程的文档,但我发现所有抽象路径都很混乱.我在Web服务器方面有很多经验,但是这有很多不同,我在理解它时遇到了很多问题.

这是我的尝试,由我在SWI-Prolog文档和上述教程中学到的(或者至少我认为的)组成:

:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_parameters)).
:- use_module(library(http/html_write)).
file_search_path('*', 'C:\\Users\\Luka\\Desktop\\').

server(Port) :-
    http_server(http_dispatch, [port(Port)]).

:- http_handler(root(.), render_base, []).
:- http_handler('/form', process_form, []).

process_form(Request) :-
    http_parameters(Request,
            [name(Name,[atom])]),
            reply_html_page('Posted data: ',['',Name]).

render_base(_Request) :-
    reply_html_page(
        title('Naslov'),
        img([src='/image.png', alt='Incident'])
    ).
Run Code Online (Sandbox Code Playgroud)

再次感谢您的巨大耐心.:-)

image prolog swi-prolog httpserver

6
推荐指数
1
解决办法
543
查看次数

Python SimpleHTTPServer 404 页面

我最近一直在使用 Python 的 SimpleHTTPServer 在我的网络上托管文件。我想要一个自定义的 404 页面,所以我研究了这个并得到了一些答案,但我仍然想使用我拥有的这个脚本。那么,我必须添加什么才能在此脚本中添加 404 页面?

import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler


HandlerClass = SimpleHTTPRequestHandler
ServerClass  = BaseHTTPServer.HTTPServer
Protocol     = "HTTP/1.0"

if sys.argv[1:]:
    port = int(sys.argv[1])
else:
    port = 80
server_address = ('192.168.1.100', port)

HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)

sa = httpd.socket.getsockname()
print "Being served on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
Run Code Online (Sandbox Code Playgroud)

python simplehttpserver httpserver

6
推荐指数
1
解决办法
5567
查看次数

什么是与 Web 服务器相关的 autoIndex?

autoIndex是什么意思,因为它与 Web 服务器有关?我有兴趣在此 Node.js 应用程序http-server的上下文中具体了解。我已经看到在有关 stackoverflow 的许多其他问题中使用的术语没有定义。

在提到的应用程序的执行选项中,它被列为“显示自动索引”,与另一个选项“显示目录列表”分开。我理解后者(显示目录列表)意味着应用程序将在用户导航到缺少默认扩展名文件的目录的情况下构建一个网页,显示指向文件和子文件夹的链接列表目录。但是,我不明白autoIndex是什么意思,因为我在网上找不到它的权威定义。谁能向我解释一下,希望链接到一些文档?

httpserver node.js web

6
推荐指数
1
解决办法
1945
查看次数

在 Nginx 中提供静态 HTML 文件而不在 url 中扩展

根目录 = /srv/myproject/xyz/main/

在“主”文件夹中,我有几个 *.html 文件,我希望它们都指向一个 url 说/test/(这与目录结构完全不同)

这是我非常基本的 nginx 配置

server {
    listen                80;
    error_log   /var/log/testc.error.log;

    location /test/ {
         root   /srv/myproject/xyz/main/;
         #alias /srv/myproject/xyz/main/;
         default_type   "text/html";
         try_files  $uri.html ;
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我使用简单别名

location /test/ {
       alias /srv/myproject/xyz/main/;   
}
Run Code Online (Sandbox Code Playgroud)

那么它的工作完美,我的意思是我可以通过http://www.myurl.com/test/firstfile.html等等访问这些html文件

但我不想要那个 html 扩展。

我试图遵循这些线程但没有成功 http://forum.nginx.org/read.php?11,201491,201494

如何使用 NGINX 从 url 中删除 .php 和 .html 扩展名?

如何在 nginx 中提供 html 文件而不在此别名设置中显示扩展名

webserver nginx httpserver

6
推荐指数
1
解决办法
3813
查看次数

Ubuntu:80 端口上的 Http 服务器启动,但无法从浏览器访问?

所以我有一个 web 应用程序运行在http-servervia 上npm。在我的package.json文件中,我有一行"start": "sudo http-server -a [my ip address] -p 8065 -c-1",当我转到http://myipaddress:8065. 但是,如果我将 8065 更改为 80,则在 json 文件中(这是我想要的),我仍然收到成功消息:

Starting up http-server, serving ./
Available on:
http://myipaddress:80
Run Code Online (Sandbox Code Playgroud)

但是当我转到链接时,chrome 给了我一个 ERR_CONNECTION_REFUSED。有人知道这是怎么回事吗?

ubuntu httpserver port80 node.js npm

6
推荐指数
2
解决办法
7648
查看次数

Angular 5修复Assets /文件夹的相对路径

我正在使用Angular 5应用,正在将其托管在Apache2.4 http服务器上,并使用代理模块对其进行重定向 http://localhost:7777/test/

我的第一个问题是调用从浏览器服务时,它是使用http://localhost:7777/作为基本URL,从我的测试服务中删除斜杠尽快解决,/service1/uploadservice1/upload。所以我从http://localhost:7777/service1/upload到了http://localhost:7777/test/service1/upload

现在我image.png在Assets /文件夹中还有一个其他未解决的问题,它一直试图从中获取它,http://localhost:7777/assets/image.png而不是http://localhost:7777/test/assets/image.png

我测试了第二个URL,它按要求返回了我的图像。如何使Angular 5相对地找到我的资产路径?以我为例http://localhost:7777/test/assets/image.png

这是我访问HTML图像的方法:

..
<img  src='assets/stop_pic.PNG' > 
..
Run Code Online (Sandbox Code Playgroud)

我的基本href在我的index.html中:

<base href="">
Run Code Online (Sandbox Code Playgroud)

我的angular-cli.json conf:

...    
apps": [
        {
          "root": "src",
          "outDir": "../src/main/resources/static",
          "assets": [
            "assets"
          ],
          "index": "index.html",
          "main": "main.ts",
          "polyfills": "polyfills.ts",
          "test": "test.ts",
          "tsconfig": "tsconfig.app.json",
          "testTsconfig": "tsconfig.spec.json",
          "prefix": "app",
          "styles": [
            "styles.css"
          ],
          "scripts": [],
          "environmentSource": "environments/environment.ts",
          "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
          }
        }
      ],
    ...
Run Code Online (Sandbox Code Playgroud)

httpserver angular angular5

6
推荐指数
1
解决办法
4543
查看次数

在 Python3 中设置简单的安全 http 服务器

我想设置非常简单的 http 服务器,它替换单个 html 文件中的几个关键字,并将其发送到响应中以请求客户端。Python 的http.server对我来说看起来不错,但在文档中我发现:

警告 http.server 不推荐用于生产。它只实现基本的安全检查。

并在源代码中:

安全警告:除非您在防火墙内,否则不要使用此代码——它可能会执行任意 Python 代码或外部程序。

你知道有什么方法可以创建安全的 http 服务器,哪些端口可以通过防火墙连接到互联网?

python security httpserver python-3.x

6
推荐指数
1
解决办法
6259
查看次数

OkHttp:&lt;-- HTTP 失败:java.net.UnknownServiceException:网络安全策略不允许与 10.0.2.2 的 CLEARTEXT 通信

我已经成功地在我的 Android 应用程序中使用 Firebase 身份验证实现了谷歌登录在此处输入图片说明

如您所见,我已使用我的帐户登录并显示在 Firebase 控制台上。

使用 Google Sign-in 登录后,函数firebaseAuthWithGoogle使用 Firebase 对用户进行身份验证:

private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mFirebaseAuth.signInWithCredential(credential)
        .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()) {
                    // Sign in success, update UI with the signed-in user's information
                    Log.d(TAG, "signInWithCredential:success");
                    final FirebaseUser user = mFirebaseAuth.getCurrentUser();


                    //This is to connect to the http server and save the user data …
Run Code Online (Sandbox Code Playgroud)

httpserver android-studio retrofit okhttp android-security

6
推荐指数
2
解决办法
5930
查看次数