GVKun编程网logo

8行代码的web server(几行代码)

9

在这里,我们将给大家分享关于8行代码的webserver的知识,让您更了解几行代码的本质,同时也会涉及到如何更有效地8行代码的模板字符串替换函数、android调用C#编写的webserver、asp

在这里,我们将给大家分享关于8行代码的web server的知识,让您更了解几行代码的本质,同时也会涉及到如何更有效地8行代码的模板字符串替换函数、android 调用C#编写的web server、asp.net – 如何在x64中使用WebDev.WebServer.exe(VS Web Server)?、Boa Webserver 小型的web服务器的内容。

本文目录一览:

8行代码的web server(几行代码)

8行代码的web server(几行代码)

Node.js Express:

1 const express = require('express')
2 const  app = express()
3 app.get('/',(req,res)=>{
4     res.send('hello world express')
5 })
6 app.listen(10000,()=>{
7     console.log('开始监听端口:10000')
8 })

 

Python Flask:

1 from flask import Flask
2 app = Flask(__name__)
3 @app.route('/')
4 def index():
5     return 'hello world flask'
6 if __name__ == '__main__':
7     print('开始监听端口:5000')
8     app.run()

 

8行代码的模板字符串替换函数

8行代码的模板字符串替换函数

特点

  • 无依赖
  • 无检查
  • 无错误处理
  • 无逻辑
  • 无配置

代码

function render(tpl, data){
    var re = /{{([^}]+)?}}/;
    var match = '''';
    while(match = re.exec(tpl)){
        tpl = tpl.replace(match[0],data[match[1]]);
    }
    return tpl;
}

demo

var tpl = ''/cube_xinbao_dial_result/{{action}}/{{report_type}}/{{query}}/?userId={{userId}}'';

var data = {report_type:1, query: ''2323'', action: ''todolist'',userId: ''23234234''}

function render(tpl, data){
    var re = /{{([^}]+)?}}/;
    var match = '''';
    while(match = re.exec(tpl)){
        tpl = tpl.replace(match[0],data[match[1]]);
    }
    return tpl;
}

console.log(render(tpl,data));

> /cube_xinbao_dial_result/todolist/1/2323/?userId=23234234

android 调用C#编写的web server

android 调用C#编写的web server

我使用android连接webService.,使用Soap解析,设置参数如下

private static final String NAMESPACE = "http://tempuri.org/";

private static String URL ="http://soap5.cyclelution.com/CyclelutionWcfService/CyclelutionService.svc";


private static final String METHOD_NAME = "ExportOfficeList";
private static String SOAP_ACTION = NAMESPACE + "ExportOfficeList";


出现下面异常,

SoapFault - faultcode: ''a:ActionNotSupported'' faultstring: ''The message with Action ''http://tempuri.org/ExportOfficeList'' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).'' faultactor: ''null'' detail: null

源代码如下:

public class Main extends Activity
{

private static final String NAMESPACE = "http://tempuri.org/";


private static String URL = "http://soap5.cyclelution.com/CyclelutionWcfService/CyclelutionService.svc";

private static final String METHOD_NAME = "ExportOfficeList";
private static String SOAP_ACTION = NAMESPACE + "ExportOfficeList";


public void getWeather()
{
try
{
new Thread()
{
public void run()
{
SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);


rpc.addProperty("CYLClientID", "86");
rpc.addProperty("UserName", "VTGAdmin");
rpc.addProperty("Password", "$%vtg876");
rpc.addProperty("SourceSystemName", "WSI");
rpc.addProperty("SourceSystemVersion", "1.0");


HttpTransportSE ht = new HttpTransportSE(URL);


ht.debug = true;
// 3.设置Soap的请求信息,参数部分为Soap协议的版本号,这里要低于服务器版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);


envelope.bodyOut = rpc;
envelope.dotNet = true;


envelope.setOutputSoapObject(rpc);


try
{
ht.call(SOAP_ACTION, envelope);


} catch (IOException e)
{
e.printStackTrace();
} catch (XmlPullParserException e)
{

String sssString = e.getMessage();
Log.v("gavin", sssString);
e.printStackTrace();
}
SoapFault fault = (SoapFault) envelope.bodyIn;
String faultcode = fault.faultcode;
//
SoapObject result = (SoapObject) envelope.bodyIn;
detail = (SoapObject) result.getProperty("CyclelutionWcfService");
// SoapFault - faultcode: ''a:ActionNotSupported''
// faultstring: ''The message with Action
// ''http://tempuri.org/ExportOfficeList'' cannot be processed
// at the receiver, due to a ContractFilter mismatch at the
// EndpointDispatcher. This may be because of either a
// contract mismatch (mismatched Actions between sender and
// receiver) or a binding/security mismatch between the
// sender and the receiver. Check that sender and receiver
// have the same contract and the same binding (including
// security requirements, e.g. Message, Transport, None).''
// faultactor: ''null'' detail: null


}
}.start();
return;
} catch (Exception e)
{
e.printStackTrace();
}
}


private String weatherToday;
private String weatherTomorrow;
private String weatherAfterday;
private String weatherCurrent;


private int iconToday[] = new int[2];
private int iconTomorrow[] = new int[2];
private int iconAfterday[] = new int[2];


private Button okButton;
private EditText textInput;
private ImageView imageView1;
private ImageView imageView2;
private TextView textWeatherToday;
private ImageView imageView3;
private ImageView imageView4;
private TextView textWeatherTomorrow;
private ImageView imageView5;
private ImageView imageView6;
private TextView textWeatherAfterday;
private TextView textWeatherCurrent;
private SoapObject detail;


@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


textInput = (EditText) findViewById(R.id.TextWeather);
okButton = (Button) findViewById(R.id.WeatherSearch);
imageView1 = (ImageView) findViewById(R.id.ImageView01);
imageView2 = (ImageView) findViewById(R.id.ImageView02);


textWeatherToday = (TextView) findViewById(R.id.WeatherToday);
imageView3 = (ImageView) findViewById(R.id.ImageView03);
imageView4 = (ImageView) findViewById(R.id.ImageView04);


textWeatherTomorrow = (TextView) findViewById(R.id.WeatherTomorrow);
imageView5 = (ImageView) findViewById(R.id.ImageView05);
imageView6 = (ImageView) findViewById(R.id.ImageView06);


textWeatherAfterday = (TextView) findViewById(R.id.WeatherAfterday);
textWeatherCurrent = (TextView) findViewById(R.id.WeatherCurrent);


okButton.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
showWeather();
// test3();
}
});
}


private void showWeather()
{


getWeather();
}
}
请问高手:问题出现在哪里?

asp.net – 如何在x64中使用WebDev.WebServer.exe(VS Web Server)?

asp.net – 如何在x64中使用WebDev.WebServer.exe(VS Web Server)?

直到至少2010年版本的Visual Studio是x86直到更新:这仍然是一个问题在VS2010,没有本机64位卡西尼支持。我的问题是,任何人都可以想到一种独立的ASP.NET调试服务器的方式或知道,这是2008年或2010年的x64?

背景:我们的ASP.NET应用程序以Oracle作为数据库运行。由于我们稍后在64位服务器上进行内存考虑,因此我们需要使用Oracle的64位驱动程序(Instant Client)。

建立:

> x64操作系统(XP或Windows 7)
> IIS(6或7,两个x64应用程序池)
> Oracle 64-bit Instant Client(PATH中的独立目录)
> Visual Studio 2008 SP1 Visual Studio 2010

在IIS中,应用程序池作为64位运行,但是由于WebDev.WebServer.exe是32位,所以您会收到一个BadImageFormatException,因为它试图加载32位的64位驱动程序DLL环境。我们所有的开发人员都希望能够通过Visual Studio 2008使用快速调试服务器,但由于它运行的是32位,我们无法使用。我们遇到的一些问题是在应用程序启动期间,所以尽管我们附加到IIS进程有时候还不足以跟踪问题。

是否有其他替代方案或解决方案?我们希望尽可能地匹配我们的Dev / Val / Prod层,所以以x64运行的所有内容都将是理想的。

VS 2010更新

自从第一次发布以来,这个问题发生了很多变化,首先是VS2010,现在还是有同样的问题,但是我没有这个项目。我们经历了2个改变来解决这个问题,所以我会发贴这些,希望能够拯救别人的悲伤:

第一个解决方案是在64位模式下将Oracle x86加载到32位x64,我们通过在64位运行时通过web.config替换程序集引用,就像这样:

<configuration>
  <runtime>
    <assemblyBinding>
      <dependentAssembly>
        <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" processorArchitecture="amd64" />
          <bindingRedirect oldVersion="2.0.0.0-10.9.9.9" newVersion="2.102.3.2" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

这里的关键是processorArchitecture =“amd64”,这意味着只有在64位下运行时才会更换。

请注意,这些版本现在可能已经过时了(如果您正在专心阅读关于Oracle的话),这是一回事。除了配置,我们加载了Oracle.DataAccess into the GAC的32位和64位版本。对于Oracle 10g,32位版本是10.xxx,64位版本是2.1xxx,所以只有swapping the binding using <assemblyBinding> works。

第二个更长期的解决方案是完全脱离Oracle客户端,我们现在正在为Linq-to-sql提供商使用dotConnect for Oracle,由于它是使用直接TCP连接的完全托管代码,因此我们不再有32/64 – 应用程序中的特定代码,这更容易维护。

我希望谁发现这也发现后续行动也是有用的。如果您有任何解决方案的问题,我最后使用,请评论,我会尝试更详细地解释。

解决方法

两个想法:

>与Mono项目中的XSP一起使用。>测试在一个完全32bit的环境中,部署到一个64位的环境。

Boa Webserver 小型的web服务器

Boa Webserver 小型的web服务器

Boa Webserver 介绍

boa是一个小型的web服务器,可以用于多种平台,在嵌入式中比较常见。

Boa Webserver 官网

http://www.boa.org/

今天关于8行代码的web server几行代码的讲解已经结束,谢谢您的阅读,如果想了解更多关于8行代码的模板字符串替换函数、android 调用C#编写的web server、asp.net – 如何在x64中使用WebDev.WebServer.exe(VS Web Server)?、Boa Webserver 小型的web服务器的相关知识,请在本站搜索。

本文标签: